automatically generate https certificates via acme
Project description
auto-acme
Automatically generate and renew HTTPS certificates using the ACME protocol (Let's Encrypt).
auto-acme is a Python package that simplifies the process of obtaining and renewing HTTPS certificates for your web applications using the ACME protocol. It integrates seamlessly with popular web frameworks like Flask, Django, and FastAPI, and can be used with any Python web server that supports SSL contexts.
Features
- Automatic Certificate Management: Obtain and renew certificates automatically.
- Let's Encrypt Support: Works with Let's Encrypt and other ACME-compatible CAs.
- Framework Agnostic: Use with Flask, Django, FastAPI, or any WSGI/ASGI server.
- Simple Configuration: Minimal setup required.
- Certificate Storage: Certificates are stored locally and reused until renewal is needed.
Installation
Install auto-acme using pip:
pip install auto-acme
Or from source:
git clone https://github.com/yourusername/auto-acme.git
cd auto-acme
pip install .
Usage
Basic Example with Flask
from flask import Flask
import auto_acme
app = Flask(__name__)
@app.route('/')
def home():
return "Automatic HTTPS-Certificate with auto-acme."
if __name__ == '__main__':
acme_context = auto_acme.AcmeContext(
certificate_path="~/.acme_certs",
acme_url="https://acme-v02.api.letsencrypt.org/directory",
hostname="example.com",
)
app.run(host="0.0.0.0", port=8443, ssl_context=acme_context)
With Django
from django.core.servers.basehttp import WSGIServer
import auto_acme
def run_django_with_acme():
acme_context = auto_acme.AcmeContext(
certificate_path="~/.acme_certs",
acme_url="https://acme-v02.api.letsencrypt.org/directory",
hostname="example.com",
)
server = WSGIServer(("0.0.0.0", 8443), WSGIHandler(), ssl_context=acme_context)
server.serve_forever()
if __name__ == "__main__":
run_django_with_acme()
Configuration
Required Parameters
| Parameter | Description |
|---|---|
certificate_path |
Directory where certificates and private keys will be stored. |
acme_url |
ACME server URL (e.g., Let's Encrypt staging or production). |
hostname |
Domain name for which the certificate will be issued. |
Optional Parameters
| Parameter | Description | Default Value |
|---|---|---|
contact |
List of emails for ACME account registration. | None |
agree_tos |
Automatically agree to the ACME server's terms of service. | False |
How It Works
Initialization: When AcmeContext is created, it checks for existing certificates. Certificate Request: If no valid certificate is found, it registers with the ACME server and requests a new certificate. Challenge Handling: Automatically responds to ACME challenges (TLS-ALPN-01). Certificate Storage: Stores the certificate and private key in the specified directory. Renewal: Automatically renews certificates before they expire.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Write tests for your changes.
- Submit a pull request.
License
auto-acme is licensed under the MIT License. See LICENSE for details.
Support
For questions, issues, or feature requests, please open an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auto_acme-1.0.0.tar.gz.
File metadata
- Download URL: auto_acme-1.0.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
949fc57bb77c682e4e2cefb6840286afa28eaefb9a6e9a2c88ffb2380d053c09
|
|
| MD5 |
e2d97951d3f274cb4c0e7121abbb740b
|
|
| BLAKE2b-256 |
efb76ef39520eb8d41d3d5253b826604bd95f1573e362f8bdbf09e055c40f310
|
File details
Details for the file auto_acme-1.0.0-py3-none-any.whl.
File metadata
- Download URL: auto_acme-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f394d9b66f87e070ae528cedc3df4737d5a16bc85a3f0edb3f0c3e3d0f2bc02
|
|
| MD5 |
fa76151cef4b8d713814e31462c47746
|
|
| BLAKE2b-256 |
cd54acded3225f236e82d40fd20ed05fad39251223c90489eef198247ee6739d
|