Using LetsEncrypt
and certbot
, I already have a certificate for the domain myapp.john.com
.
I was trying to expand certificate to a subdomain (prod.myapp.john.com
) by:
sudo certbot certonly --webroot -w /usr/share/nginx/html/ -d prod.myapp.john.com --expand
It was successful:
ubuntu@ip-177.77.77.77:~/sites$ sudo certbot certonly --webroot -w /usr/share/nginx/html/ -d prod.myapp.john.com --expand
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Cert not yet due for renewal
You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
(ref: /etc/letsencrypt/renewal/prod.myapp.john.com.conf)
What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Keep the existing certificate for now
2: Renew & replace the cert (limit ~5 per 7 days)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
Keeping the existing certificate
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Certificate not yet due for renewal; no action taken.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I can confirm that a new certificate is in place:
ubuntu@ip-177.77.77.77:~/sites$ sudo certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
Certificate Name: myapp.john.com
Domains: myapp.john.com www.myapp.john.com
Expiry Date: 2021-12-14 10:54:17+00:00 (VALID: 89 days)
Certificate Path: /etc/letsencrypt/live/myapp.john.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/myapp.john.com/privkey.pem
Certificate Name: prod.myapp.john.com
Domains: prod.myapp.john.com
Expiry Date: 2021-12-14 11:58:18+00:00 (VALID: 89 days)
Certificate Path: /etc/letsencrypt/live/prod.myapp.john.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/prod.myapp.john.com/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
However, when I do the same for another subdomain (test.myapp.john.com
):
sudo certbot certonly --webroot -w /usr/share/nginx/html/ -d test.myapp.john.com --expand
It throws error:
ubuntu@ip-177.77.77.77:~/sites$ sudo certbot certonly --webroot -w /usr/share/nginx/html/ -d test.myapp.john.com --expand
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for test.myapp.john.com
Using the webroot path /usr/share/nginx/html for all unmatched domains.
Waiting for verification...
Challenge failed for domain test.myapp.john.com
http-01 challenge for test.myapp.john.com
Cleaning up challenges
Some challenges have failed.
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: test.myapp.john.com
Type: unauthorized
Detail: Invalid response from
https://test.myapp.john.com/.well-known/acme-challenge/PI-mREAt2RL6RzwLC0_ERjWcrIsyNBCfoOoo9SDPrPA
[52.197.191.237]: "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n
<meta charset=\"utf-8\" />\n <link rel=\"icon\"
href=\"/favicon.ico\" />\n <!-- <lin"
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
It does not make sense to me since in my DNS hoster I have an A
record set up for test.myapp.john.com
exactly the same as for prod.myapp.john.com
and points to the same ip address.
Why does it fail?
And moreover, this also fails:
sudo certbot certonly --webroot -w /usr/share/nginx/html/ -d www.prod.myapp.john.com --expand
Error message:
ubuntu@ip-177.77.77.77:~/sites$ sudo certbot certonly --webroot -w /usr/share/nginx/html/ -d www.prod.myapp.john.com --expand
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for www.prod.myapp.john.com
Using the webroot path /usr/share/nginx/html for all unmatched domains.
Waiting for verification...
Challenge failed for domain www.prod.myapp.john.com
http-01 challenge for www.prod.myapp.john.com
Cleaning up challenges
Some challenges have failed.
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: www.prod.myapp.john.com
Type: unauthorized
Detail: Invalid response from
https://www.prod.myapp.john.com/.well-known/acme-challenge/aoocODOWb5VWIYuD37fBk8m8504YIdwLUiBslnttxwE
[52.197.191.237]: "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n
<meta charset=\"utf-8\" />\n <link rel=\"icon\"
href=\"/favicon.ico\" />\n <!-- <lin"
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.