Skip to main content

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",
        agree_tos=True,
    )
    app.run(host="0.0.0.0", port=443, 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",
        agree_tos=True,
    )
    server = WSGIServer(("0.0.0.0", 443), 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auto_acme-1.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auto_acme-1.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file auto_acme-1.1.0.tar.gz.

File metadata

  • Download URL: auto_acme-1.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for auto_acme-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2270fea029717dc3bd88f8cbea636b848cc8cc793e6666335342e257e8c47830
MD5 8c78a89b4679b3d2447816e73759f290
BLAKE2b-256 d0583aa0dd9b500d4936fddb3ec366c5bf7d608ff69523b66c2d8ffa633e8859

See more details on using hashes here.

File details

Details for the file auto_acme-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: auto_acme-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for auto_acme-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 806be65aac286f72ef84d8b25d20167828b2d2d63b7679f6f34491829a25bf3a
MD5 93f83990652248d3a0bcbde836b5d5b1
BLAKE2b-256 8a840465e84c7428b820e7263504b0a67333381204dbbf95f73b7c479b2f48f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page