Hello,
This is a continuation of another post Generate/Request or Renew SSL Cert using Python script.
I was able to get started and I'm at the point where I'm running the DNS-01 challenge but the operation seems to time out. I will try to describe in details everything I have done and the exact error below.
In my code I'm performing an AUTH to my AWS Account. This will allow me to later update the DNS TXT record via the script. I'm not showing it here since it has sensitive info.
Below is the snippet of the code that I am using to make a request for a certificate.
# Create account key
acc_key = jose.JWKRSA(
key=rsa.generate_private_key(
public_exponent=65537, key_size=ACC_KEY_BITS, backend=default_backend()
)
)
# Register account and accept TOS
net = client.ClientNetwork(acc_key, user_agent=USER_AGENT)
directory = client.ClientV2.get_directory(DIRECTORY_URL, net)
client_acme = client.ClientV2(directory, net=net)
# Terms of Service URL is in client_acme.directory.meta.terms_of_service
# Registration Resource: regr
# Creates account with contact information.
email = "someone@example.com"
regr = client_acme.new_account(
messages.NewRegistration.from_data(email=email, terms_of_service_agreed=True)
)
# Create domain private key and CSR
pkey_pem, csr_pem = new_csr_comp(DOMAIN)
# Issue certificate
orderr = client_acme.new_order(csr_pem)
# Set up DNS-01 challenge
setup_dns_challenge(client_acme, orderr)
# Poll the authorization status and finalize the order
poll_and_finalize(
client_acme, orderr, time.time() + 300
) # Poll for 5 minutes (300 seconds)
# Change contact information
email = "someone@example.com"
regr = client_acme.update_registration(
regr.update(body=regr.body.update(contact=("mailto:" + email,)))
)
# Deactivate account/registration
regr = client_acme.deactivate_registration(regr)
When I run this code it spits out the following:
AWS authentication successful.
{list of S3 buckets here - omitted}
Challenge URI: https://acme-staging-v02.api.letsencrypt.org/acme/chall-v3/7541252244/p_Vj7A
DNS-01 validation string: a2bjf63LsP2naC2YuRX-gqRm6ae3M_t8H8qvd45L0MQ
Adding TXT record: _acme-challenge.test.example.com -> a2bjf63LsP2naC2YuRX-gqRm6ae3M_t8H8qvd45L0MQ
TXT record added successfully: _acme-challenge.test.example.com -> a2bjf63LsP2naC2YuRX-gqRm6ae3M_t8H8qvd45L0MQ
NOTE: I'm using a domain that I'm hosting in the AWS I'm authenticating to and for the sake of this thread I changed it to example.com
.
As it shows, I am able to successfully update the DNS via the script, and I also test it with nslookup
nslookup -type=TXT _acme-challenge.test.example.com ns-369.awsdns-46.com.
Server: ns-369.awsdns-46.com.
Address: 205.251.193.113#53
_acme-challenge.test.example.com text = "a2bjf63LsP2naC2YuRX-gqRm6ae3M_t8H8qvd45L0MQ"
Here is where I'm experiencing the problem. Even though the DNS is correct, the function times out.
# Poll the authorization status and finalize the order
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nk/Documents/Python/lets-encrypt/t2.py", line 93, in setup_dns_challenge
client_acme.poll_and_finalize(orderr)
File "/Users/nk/Documents/nk/lib/python3.11/site-packages/acme/client.py", line 185, in poll_and_finalize
orderr = self.poll_authorizations(orderr, deadline)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nk/Documents/nk/lib/python3.11/site-packages/acme/client.py", line 202, in poll_authorizations
raise errors.TimeoutError()
acme.errors.TimeoutError
Does anyone know why it won't complete the DNS-01 challenge?
Thanks!