Library for python3 with DNS challenge

Hi,

I wonder which library for python3 I should use to generate a DNS token and then download the certificate. I have a function which updates the TXT record for my domain. I just need to have a library where I can can get the TXT record I should update to and also to download the cert. Hope you understand what I am getting at :slight_smile:

Thanks in advance

  • Alexander

You’re looking for a Python library that implements the ACME protocol. Things are slightly more involved than retrieving a DNS record and downloading the certificate, though that is part of it.

Your best bet is probably the Python acme library - https://pypi.org/project/acme/ . However, it has the problem of having very out of date documentation.

I think maybe if you want an easy to use approach, you can just use Certbot in combination with a manual auth hook.

For example,

certbot certonly --manual -d example.org -d www.example.org \
--preferred-challenges dns \
--manual-auth-hook "/path/to/dns.py deploy" \
--manual-cleanup-hook "/path/to/dns.py cleanup"

Certbot will run your Python script with environment variables containing the DNS record and you can use that to deploy the TXT record. At the end, Certbot will automatically download your certificate.

This is probably a much simpler path unless you want to implement an entire ACME client, which is quite involved.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.