Skip to main content

Pico ACME: tiny ACMEv2 client

Project description

pico acme

The tiniest python package to get ACMEv2 certs from Let's Encrypt.

Supports only single domains and DNS challenge. Currently implements AWS Route 53 but you can trivially implement your own provider.

Licensed under Apache 2.0 as this reuses some code from certbot.

quick start

Note that you need to install boto3 separately to use route53.

Create the following files in a folder:

new.py:

ROUTE53_HOSTED_ZONE_ID = "..."
ACCOUNT_EMAIL = "domains@example.com"
DOMAIN = "example.com"

# create account, get cert, and save details
import pico_acme
from pico_acme import route53

# register an acme account
acme_client = pico_acme.register_account(ACCOUNT_EMAIL, agree_tos=True)

# create a private key and certificate signing request
key_pem = pico_acme.make_key()
csr_pem = pico_acme.make_csr(key_pem, [DOMAIN])

# get functions for upserting and cleaning up DNS records in AWS Route 53
upsert, clean = route53.route53_upsert_cleanup(ROUTE53_HOSTED_ZONE_ID)

# perform DNS-01 challenge to get the full chain as PEM
fullchain_pem = pico_acme.perform_dns01(acme_client, DOMAIN, csr_pem, upsert, clean)

# save account for later
with open("pico_acme_account.json", "w") as f:
    f.write(pico_acme.serialize_account(acme_client))

# save private key for later
with open("key.pem", "wb") as f:
    f.write(key_pem)

# save the cert for later
with open("fullchain.pem", "w") as f:
    f.write(fullchain_pem)

renew.py:

ROUTE53_HOSTED_ZONE_ID = "..."
DOMAIN = "example.com"

# later, load account, private key, and renew cert
import pico_acme
from pico_acme import route53

# load account
with open("pico_acme_account.json") as f:
    acme_client = pico_acme.deserialize_account(f.read())

# load private key
with open("key.pem", "rb") as f:
    key_pem = f.read()

# make a new certificate signing request
csr_pem = pico_acme.make_csr(key_pem, [DOMAIN])

# get functions for upserting and cleaning up DNS records in AWS Route 53
upsert, clean = route53.route53_upsert_cleanup(ROUTE53_HOSTED_ZONE_ID)

# perform DNS-01 challenge to get the full chain as PEM
fullchain_pem = pico_acme.perform_dns01(acme_client, DOMAIN, csr_pem, upsert, clean)

# save the cert for later
with open("fullchain.pem", "w") as f:
    f.write(fullchain_pem)

architecture & features

The perform_dns01 takes two callables, upsert(record, value) which should set the value value (the verification string) in record record (e.g. _acme-challenge.example.com), and clean(record, value) which should clean these up. See the route53.py implementation for details.

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

pico_acme-0.0.3.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

pico_acme-0.0.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file pico_acme-0.0.3.tar.gz.

File metadata

  • Download URL: pico_acme-0.0.3.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for pico_acme-0.0.3.tar.gz
Algorithm Hash digest
SHA256 fb7ff577498180bb0c3eab18d8f45f9d1ad6d584ba7bba14624b125a02967c57
MD5 67b4b6e28c877a2892ffdec804fe4572
BLAKE2b-256 507b8e399d7c04a217bc2602ba7b7957d6876f4467df35f5dc5e8cc95160b602

See more details on using hashes here.

File details

Details for the file pico_acme-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pico_acme-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for pico_acme-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 44400d1db8b459e0515764a71b78d27dfcd7cfa93ab1bb211418a04573b424fd
MD5 b82be690a787f078002e61cbbc488d1c
BLAKE2b-256 36d9770e47f7547710b59a9b12aa07827fbbcbb6261577f6ddad764424b60a90

See more details on using hashes here.

Supported by

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