Incorrect validation certificate when creating cert

Hello all,

I’m a new member to this community as this is my first post. I was following the certbot manual and this is how far I got. We are using sucuri for this site which I’m not sure how that effects it or should have any effect on it. Any help is appreciated.

sudo certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
No names were found in your configuration files. Please enter in your domain
name(s) (comma and/or space separated)  (Enter 'c' to cancel):mysite.com
Obtaining a new certificate
Performing the following challenges:
tls-sni-01 challenge for mysite.com
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. mysite.com (tls-sni-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Incorrect validation certificate for tls-sni-01 challenge. Requested 77bc0d85ccb69e854576989f616b4172.6aa0529f29746adbfaf6ed3c10f8fb53.acme.invalid from 192.124.249.6:443. Received 3 certificate(s), first certificate had names "*.sucuri.net, sucuri.net"

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: mysite.com
   Type:   unauthorized
   Detail: Incorrect validation certificate for tls-sni-01 challenge.
   Requested
   77bc0d85ccb69e854576989f616b4172.6aa0529f29746adbfaf6ed3c10f8fb53.acme.invalid
   from 192.124.249.6:443. Received 3 certificate(s), first
   certificate had names "*.sucuri.net, sucuri.net"

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A record(s) for that domain
   contain(s) the right IP address.

Hi @kumamari, welcome to the Let’s Encrypt community! :tada:

Does Securi terminate TLS/HTTPS for you like a CDN might (e.g. Cloudflare)? If so I suspect this is the root cause of your problem. The Apache plugin uses the TLS-SNI-01 challenge under the hood. This involves the Certificate Authority making a TLS request to your site with a special SNI value that Certbot configures Apache to expect. When Apache sees that SNI value it is supposed to return a special challenge response certificate. In this case it looks like Securi is terminating TLS and instead of giving back the challenge certificate it’s returning a normal certificate for the names “*.sucuri.net” and “sucuri.net”.

I suspect the best fit for this case (if my assumptions so far are correct!) is to switch to the webroot plugin. This will use an HTTP-01 challenge where the CA asks for a specific file under the /.well-known/acme-challenge path of your website. Securi will likely pass that request on to your Apache server and everything should work.

Hope this helps!

Hello cpu,

Thanks for your help. I am now getting an error involving the .well-known directory inside of my /var/www/html directory.

certbot certonly --webroot -w /var/www/html/ -d www.mysite.com -d mysite.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for www.mysite.com
http-01 challenge for mysite.com
Using the webroot path /var/www/html for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. mysite.com (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://mysite.com/.well-known/acme-challenge/C7dzkA3px4FyF25GvOeo1mInvIB3QTUUcRvM_8B8Jxk: "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p", www.mysite.com (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.mysite.com/.well-known/acme-challenge/2dssFKb7woNHgdyXzdviPT6A9ZRT0lx2brmXpwdJuxI: "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p"

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: mysite.com
   Type:   unauthorized
   Detail: Invalid response from
   http://mysite.com/.well-known/acme-challenge/C7dzkA3px4FyF25GvOeo1mInvIB3QTUUcRvM_8B8Jxk:
   "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
   <html><head>
   <title>404 Not Found</title>
   </head><body>
   <h1>Not Found</h1>
   <p"

   Domain: www.mysite.com
   Type:   unauthorized
   Detail: Invalid response from
   http://www.mysite.com/.well-known/acme-challenge/2dssFKb7woNHgdyXzdviPT6A9ZRT0lx2brmXpwdJuxI:
   "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
   <html><head>
   <title>404 Not Found</title>
   </head><body>
   <h1>Not Found</h1>
   <p"

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A record(s) for that domain
   contain(s) the right IP address.

Is this a permission issue or another issue?

Hi @kumamari,

Can you share your Apache configuration? It would also be worthwhile to manually create a file in your webroot in the /.well-known/acme-challenge/ folder and see if you can access it in your browser.

There is no acme-challenge folder in there. I went ahead and created one and ran the command, then it got rid of it. I can access my txt file inside of the .well-known folder.

# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
#	/etc/apache2/
#	|-- apache2.conf
#	|	`--  ports.conf
#	|-- mods-enabled
#	|	|-- *.load
#	|	`-- *.conf
#	|-- conf-enabled
#	|	`-- *.conf
# 	`-- sites-enabled
#	 	`-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
#
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

#
# The directory where shm and other runtime files will be stored.
#

DefaultRuntimeDir ${APACHE_RUN_DIR}

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
	Options FollowSymLinks
	AllowOverride None
	Require all denied
</Directory>

<Directory /usr/share>
	AllowOverride None
	Require all granted
</Directory>

<Directory /var/www/>
	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted
</Directory>

#<Directory /srv/>
#	Options Indexes FollowSymLinks
#	AllowOverride None
#	Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
	Require all denied
</FilesMatch>


#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
ServerName XXX.XX.XXX.XXX

@schoen, @SwartzCr - Are either of you able to help @kumamari? I’m out of my depth w.r.t client-side Certbot debugging and don’t see anything obvious. Thanks!

Hi @kumamari, where is the test file stored locally on your server? And what URL can you access it at on the web?

Hello @schoen, it is located at /var/www/html/.well-known/

The url is http://www.diamondchain.com/.well-known/test.txt

Can you also make one in /var/www/html/.well-known/acme-challenge?

Also, do you know if Sucuri is proxying the HTTP connections too? Is there any chance that they would fail to pass through a particular request for some reason?

So something that’s pretty suspicious here is that the 404 page on your own site begins with

<!doctype html>

  <html class="no-js"  lang="en-US" prefix="og: http://ogp.me/ns#">

whereas the 404 page that the certificate authority received was

   "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
   <html><head>
   <title>404 Not Found</title>
   </head><body>
   <h1>Not Found</h1>

which is seemingly from some other server. Is there any chance that this is a result of using Sucuri, or that your configuration has changed abruptly recently, or that you have a typo somewhere leading the certificate authority to go to someone else’s site entirely?

Edit: your site gives different 404 messages for .well-known and for .well-known/acme-challenge, I think, so this might be a false alarm.

I made a new folder (acme-challenge) in .well-known and then I did touch testtwo.txt

So right now, I got a 404 error for

http://www.diamondchain.com/.well-known/acme-challenge/testtwo.txt

Do you see the same result?

Yes, I am getting that same result.

Do you understand enough about Apache configuration to figure out why the file in .well-known is being served but the file in .well-known/acme-challenge isn’t? I think that’s the same reason that you can’t get the certificate via this method.

Yeah, I’m familiar with Apache. Any pointers always helps if you see something blatantly out of place. As always two sets of eyes is better then one. :slight_smile:

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