Library for python3 with DNS challenge


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 - . 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 -d \
--preferred-challenges dns \
--manual-auth-hook "/path/to/ deploy" \
--manual-cleanup-hook "/path/to/ 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.


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