Blog · 02/10/2021
Virtualmin fails to renew the domain certificate
Virtualmin and SSL Certificates
Virtualmin has the ability to request and renew certificates using Let's Encrypt, new certificates can be requested and renewed, automatically or manually.
Let's Encrypt is a free, automated and open certification authority that can be used to generate a SSL certificate using Virtualmin.
This allows you to easily add the Https protocol to the web pages hosted on the Webmin server.
The certificate generated by Let's Encrypt has a validity of 3 months.
It is also possible through Virtualmin to include payment certificates, these have a validity in most cases of 1 year.
The advantage that Virtualmin offers is that it allows you to automatically renew the generator certificates by Let's Encrypt in such a way that validity time ceases to be a disadvantage.
An expired SSL certificate warning, how to fix it?
When Webmin detects using Virtualmin that there is an expired certificate, this shows you on the main page:

This is done with the intention that you review that has passed, since normally the renewal of the certificates is completely transparent.
Even if it fails, as has been in this case, it will show a warning message.
If we go to the certificate generation screen we will find that the certificate has expired and the number of days it takes expired:

The error then occurs now, when trying to request or update the certificate, for some strange reason it was impossible to renew it, launching the system the following error:
2021-10-02 22:35:09,472:INFO:certbot.auth_handler:http-01 challenge for facturascripts.narixasoft.es
2021-10-02 22:35:09,473:INFO:certbot.plugins.webroot:Using the webroot path /home/facturascripts/public_html for all unmatched domains.
2021-10-02 22:35:09,473:DEBUG:certbot.plugins.webroot:Creating root challenges validation dir at /home/facturascripts/public_html/.well-known/acme-challenge
2021-10-02 22:35:09,478:DEBUG:certbot.plugins.webroot:Attempting to save validation to /home/facturascripts/public_html/.well-known/acme-challenge/rWyH4VSwowD1WmFfrUkwahUMCkLnfUein-AcTCa-u8Y
"value": "facturascripts.narixasoft.es"
"detail": "Invalid response from http://facturascripts.narixasoft.es/.well-known/acme-challenge/rWyH4VSwowD1WmFfrUkwahUMCkLnfUein-AcTCa-u8Y [185.137.140.9]: \"\u003c!DOCTYPE html\u003e\\n\u003chtml xmlns=\\\"http://www.w3.org/1999/xhtml\\\" lang=\\\"es\\\" xml:lang=\\\"es\\\" \u003e\\n \u003chead\u003e\\n \u003cmeta http-e\"",
"url": "http://facturascripts.narixasoft.es/.well-known/acme-challenge/rWyH4VSwowD1WmFfrUkwahUMCkLnfUein-AcTCa-u8Y",
"hostname": "facturascripts.narixasoft.es",
Domain: facturascripts.narixasoft.es
Detail: Invalid response from http://facturascripts.narixasoft.es/.well-known/acme-challenge/rWyH4VSwowD1WmFfrUkwahUMCkLnfUein-AcTCa-u8Y [185.137.140.9]: "<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"es\" xml:lang=\"es\" >\n <head>\n <meta http-e"
certbot.errors.FailedChallenges: Failed authorization procedure. facturascripts.narixasoft.es (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://facturascripts.narixasoft.es/.well-known/acme-challenge/rWyH4VSwowD1WmFfrUkwahUMCkLnfUein-AcTCa-u8Y [185.137.140.9]: "<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"es\" xml:lang=\"es\" >\n <head>\n <meta http-e"
2021-10-02 22:35:12,954:DEBUG:certbot.plugins.webroot:Removing /home/facturascripts/public_html/.well-known/acme-challenge/rWyH4VSwowD1WmFfrUkwahUMCkLnfUein-AcTCa-u8Y
certbot.errors.FailedChallenges: Failed authorization procedure. facturascripts.narixasoft.es (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://facturascripts.narixasoft.es/.well-known/acme-challenge/rWyH4VSwowD1WmFfrUkwahUMCkLnfUein-AcTCa-u8Y [185.137.140.9]: "<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"es\" xml:lang=\"es\" >\n <head>\n <meta http-e"
2021-10-02 22:35:14,332:DEBUG:certbot.main:Arguments: ['--manual', '-d', 'facturascripts.narixasoft.es', '--preferred-challenges=dns', '--manual-auth-hook', '/etc/webmin/webmin/letsencrypt-dns.pl', '--manual-cleanup-hook', '/etc/webmin/webmin/letsencrypt-cleanup.pl', '--duplicate', '--force-renewal', '--manual-public-ip-logging-ok', '--non-interactive', '--agree-tos', '--config', '/tmp/.webmin/936363_29724_4_collectinfo.pl', '--rsa-key-size', '2048', '--cert-name', 'facturascripts.narixasoft.es']
b'{\n "identifiers": [\n {\n "type": "dns",\n "value": "facturascripts.narixasoft.es"\n }\n ]\n}'
"value": "facturascripts.narixasoft.es"
"value": "facturascripts.narixasoft.es"
2021-10-02 22:35:16,239:INFO:certbot.auth_handler:dns-01 challenge for facturascripts.narixasoft.es
"value": "facturascripts.narixasoft.es"
"detail": "DNS problem: NXDOMAIN looking up TXT for _acme-challenge.facturascripts.narixasoft.es - check that a DNS record exists for this domain",
Domain: facturascripts.narixasoft.es
Detail: DNS problem: NXDOMAIN looking up TXT for _acme-challenge.facturascripts.narixasoft.es - check that a DNS record exists for this domain
Analysis of the problem
It seems that something rare happened with the validation file that is added temporarily to the root of the web so that Let's Encrypt can validate the domain.
Before any certificate validation error case the main thing is to make sure that the DNS is pointing to the domain using nslookup:
C:\Users\José Miguel>nslookup facturascripts.narixasoft.es Servidor: 254.red-80-58-61.staticip.rima-tde.net Address: 80.58.61.254Respuesta no autoritativa:
Nombre: facturascripts.narixasoft.es
Address: 185.137.140.9C:\Users\José Miguel>nslookup www.facturascripts.narixasoft.es
Servidor: 254.red-80-58-61.staticip.rima-tde.net
Address: 80.58.61.254Respuesta no autoritativa:
Nombre: www.facturascripts.narixasoft.es
Address: 185.137.140.9
In this case, everything was correct, since the domain points, both in its normal version and www to the ip: 185.137.140.9, which is the correct in this case.
Then, the following step is to review the Apache settings for the specific server to check if there is any parameter that was influencing the review:



SSL Certified Renewal Solution in Virtualmin
And just there was the error, in this case the PHP FPM server is used, so the CGI engine should not be referred there.
Therefore, the line to remove and that fixes the error of the renewal of the certificate is:
Redirect /.well-known/autoconfig/mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
Certainly this line was when at the beginning the server was using the PHP CGI engine, there if it would have sense this line for the correct operation.
But when using the PHP FPM engine this line does not have to exist, as it would be calling the CGI engine that in this case is completely disabled.
After these changes, the server certificate has been properly renewed.
