Can't retrieve Issuer Certificate

Hello, I am trying to set up Let’s Encrypt on my Ubuntu 16.04 server, and I was sent here from Digital Ocean. I thought I installed and ran the right tutorial to install LE with nginx, when I was told I should have done the tutorial to install LE with apache. I am being told when I go to run the command:

sudo certbot --apache -d haracoin.com -d www.haracoin.com

The certificate is created successfully created, but I still get the warning that my server is not secure. My apache log also says (info is changed for security reasons):

[Thu Sep 21 15:13:57.319938 2017] [ssl:error] [pid 1577] AH02604: Unable to configure certificate 
104.236.153.107:443:0 for stapling
[Thu Sep 21 15:13:57.321538 2017] [mpm_prefork:notice] [pid 1577] AH00163: Apache/2.4.18 (Ubuntu) 
OpenSSL/1.0.2g configured -- resuming normal operations
[Thu Sep 21 15:13:57.321551 2017] [core:notice] [pid 1577] AH00094: Command line: '/usr/sbin/apache2'
[Thu Sep 21 15:14:03.543145 2017] [mpm_prefork:notice] [pid 1577] AH00171: Graceful restart requested, doing 
restart
[Thu Sep 21 15:14:03.826324 2017] [ssl:warn] [pid 1577] AH01906: 104.236.153.107:443:0 server certificate is a CA 
certificate (BasicConstraints: CA == TRUE !?)
[Thu Sep 21 15:14:03.830474 2017] [ssl:warn] [pid 1577] AH01909: 104.236.153.107:443:0 server certificate does 
NOT include an ID which matches the server name
[Thu Sep 21 15:14:03.830899 2017] [ssl:error] [pid 1577] AH02217: ssl_stapling_init_cert: can't retrieve issuer 
certificate! [subject: emailAddress=nickd@miyuholdings.com,O=MiYu Holdings\\, Inc.,L=Orem,ST=Utah,C=US / 
issuer: emailAddress=nickd@miyuholdings.com,O=MiYu Holdings\\, Inc.,L=Orem,ST=Utah,C=US / serial: 
C308F1E20C637C59 / notbefore: Sep  8 20:51:25 2017 GMT / notafter: Sep  8 20:51:25 2018 GMT]

I see that my logs are saying it can’t find my certificate, and that the server cert is not a CA cert. I had started the server using self-signed certificates, if that has anything to do with it. Thank you for any help you can provide.

It looks to me like your self-signed certificate is still in effect. Perhaps Certbot added an additional configuration in /etc/apache2/sites-enabled referring to the new Let’s Encrypt certificate, but it wouldn’t have removed your old configuration pointing to the self-signed certificate. You should do so yourself, either by switching everything to the new Certbot-created virtual host, or editing the configuration of your previous virtual host to point at the appropriate PEM files in /etc/letsencrypt/live.

Ok, thank you for helping me understand what is happening. After looking through my /etc/apache2/sites-enabled folder, I looked in the 000-default-le-ssl.conf file, and saw these 2 lines:

SSLCertificateFile /etc/letsencrypt/live/haracoin.com-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/haracoin.com-0001/privkey.pem

but when I look in my default-ssl.conf file, I see these 2 lines not un-commented under the self-signed (snakeoil) cert section:

SSLCertificateFile      /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key

I am still fairly new at this, so I am wondering if I should I comment them out, or replace them with the .pem files from letsencrypt?

I would suggest disabling the self-signed certificate in the default-ssl.conf file.

Is there a reference to the domain name haracoin.com itself in the default-ssl.conf file? If you removed that reference, Apache would no longer think it should use the self-signed certificate in response to requests related to haracoin.com.

This is what is in my default-ssl.conf file:

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
	ServerAdmin nickd@miyuholdings.com
	ServerName 104.236.153.107
	DocumentRoot /var/www/html

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf

	#   SSL Engine Switch:
	#   Enable/Disable SSL for this virtual host.
	SSLEngine on

	#   A self-signed (snakeoil) certificate can be created by installing
	#   the ssl-cert package. See
	#   /usr/share/doc/apache2/README.Debian.gz for more info.
	#   If both key and certificate are stored in the same file, only the
	#   SSLCertificateFile directive is needed.
	#SSLCertificateFile	/etc/ssl/certs/apache-selfsigned.crt
	#SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key

	#   Server Certificate Chain:
	#   Point SSLCertificateChainFile at a file containing the
	#   concatenation of PEM encoded CA certificates which form the
	#   certificate chain for the server certificate. Alternatively
	#   the referenced file can be the same as SSLCertificateFile
	#   when the CA certificates are directly appended to the server
	#   certificate for convinience.
	#SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt

	#   Certificate Authority (CA):
	#   Set the CA certificate verification path where to find CA
	#   certificates for client authentication or alternatively one
	#   huge file containing all of them (file must be PEM encoded)
	#   Note: Inside SSLCACertificatePath you need hash symlinks
	#		 to point to the certificate files. Use the provided
	#		 Makefile to update the hash symlinks after changes.
	#SSLCACertificatePath /etc/ssl/certs/
	#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt

	#   Certificate Revocation Lists (CRL):
	#   Set the CA revocation path where to find CA CRLs for client
	#   authentication or alternatively one huge file containing all
	#   of them (file must be PEM encoded)
	#   Note: Inside SSLCARevocationPath you need hash symlinks
	#		 to point to the certificate files. Use the provided
	#		 Makefile to update the hash symlinks after changes.
	#SSLCARevocationPath /etc/apache2/ssl.crl/
	#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl

	#   Client Authentication (Type):
	#   Client certificate verification type and depth.  Types are
	#   none, optional, require and optional_no_ca.  Depth is a
	#   number which specifies how deeply to verify the certificate
	#   issuer chain before deciding the certificate is not valid.
	#SSLVerifyClient require
	#SSLVerifyDepth  10

	#   SSL Engine Options:
	#   Set various options for the SSL engine.
	#   o FakeBasicAuth:
	#	 Translate the client X.509 into a Basic Authorisation.  This means that
	#	 the standard Auth/DBMAuth methods can be used for access control.  The
	#	 user name is the `one line' version of the client's X.509 certificate.
	#	 Note that no password is obtained from the user. Every entry in the user
	#	 file needs this password: `xxj31ZMTZzkVA'.
	#   o ExportCertData:
	#	 This exports two additional environment variables: SSL_CLIENT_CERT and
	#	 SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
	#	 server (always existing) and the client (only existing when client
	#	 authentication is used). This can be used to import the certificates
	#	 into CGI scripts.
	#   o StdEnvVars:
	#	 This exports the standard SSL/TLS related `SSL_*' environment variables.
	#	 Per default this exportation is switched off for performance reasons,
	#	 because the extraction step is an expensive operation and is usually
	#	 useless for serving static content. So one usually enables the
	#	 exportation for CGI and SSI requests only.
	#   o OptRenegotiate:
	#	 This enables optimized SSL connection renegotiation handling when SSL
	#	 directives are used in per-directory context.
	#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
	<FilesMatch "\.(cgi|shtml|phtml|php)$">
			SSLOptions +StdEnvVars
	</FilesMatch>
	<Directory /usr/lib/cgi-bin>
			SSLOptions +StdEnvVars
	</Directory>

	#   SSL Protocol Adjustments:
	#   The safe and default but still SSL/TLS standard compliant shutdown
	#   approach is that mod_ssl sends the close notify alert but doesn't wait for
	#   the close notify alert from client. When you need a different shutdown
	#   approach you can use one of the following variables:
	#   o ssl-unclean-shutdown:
	#	 This forces an unclean shutdown when the connection is closed, i.e. no
	#	 SSL close notify alert is send or allowed to received.  This violates
	#	 the SSL/TLS standard but is needed for some brain-dead browsers. Use
	#	 this when you receive I/O errors because of the standard approach where
	#	 mod_ssl sends the close notify alert.
	#   o ssl-accurate-shutdown:
	#	 This forces an accurate shutdown when the connection is closed, i.e. a
	#	 SSL close notify alert is send and mod_ssl waits for the close notify
	#	 alert of the client. This is 100% SSL/TLS standard compliant, but in
	#	 practice often causes hanging connections with brain-dead browsers. Use
	#	 this only for browsers where you know that their SSL implementation
	#	 works correctly.
	#   Notice: Most problems of broken clients are also related to the HTTP
	#   keep-alive facility, so you usually additionally want to disable
	#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
	#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
	#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
	#   "force-response-1.0" for this.
	 BrowserMatch "MSIE [2-6]" \
			nokeepalive ssl-unclean-shutdown \
			downgrade-1.0 force-response-1.0

    </VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

so I did a search by doing /haracoin.com and nothing came up, so I assume not

After messing with some things, I did a tail of the apache2 error log, and this is what came up:

[Thu Sep 21 17:40:55.497230 2017] [ssl:warn] [pid 5882] AH01909: 104.236.153.107:443:0 server certificate does 
NOT include an ID which matches the server name
[Thu Sep 21 17:40:55.562173 2017] [ssl:warn] [pid 5883] AH01909: 104.236.153.107:443:0 server certificate does 
NOT include an ID which matches the server name
[Thu Sep 21 17:40:55.572829 2017] [mpm_prefork:notice] [pid 5883] AH00163: Apache/2.4.18 (Ubuntu) 
OpenSSL/1.0.2g configured -- resuming normal operations
[Thu Sep 21 17:40:55.572890 2017] [core:notice] [pid 5883] AH00094: Command line: '/usr/sbin/apache2'
[Thu Sep 21 17:45:45.087015 2017] [mpm_prefork:notice] [pid 5883] AH00169: caught SIGTERM, shutting down

It appears to have found the cert, but cannot match the ID to the server name. I assume it means the server name in the default-ssl.conf file, or somewhere else?

@bmw, do you think we have a position on the right thing to do when someone had an existing self-signed cert in place before running certbot --apache?

Hi @Azotherian,

Your site is serving the correct certificate:

$ echo | openssl s_client -connect haracoin.com:443 -servername haracoin.com 2>/dev/null | openssl x509 -noout -dates  -issuer

notBefore=Sep 21 14:14:00 2017 GMT
notAfter=Dec 20 14:14:00 2017 GMT
issuer= /C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3

$ echo | openssl s_client -connect haracoin.com:443 -servername haracoin.com 2>/dev/null | openssl x509 -noout -text |grep DNS
                DNS:haracoin.com, DNS:www.haracoin.com

The problem is that you have a redirection from that domain to scheme://104.236.153.107/whatever

curl -IkL http://haracoin.com
HTTP/1.1 301 Moved Permanently
Date: Thu, 21 Sep 2017 19:04:02 GMT
Server: Apache/2.4.18 (Ubuntu)
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Location: https://haracoin.com/
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 301 Moved Permanently
Date: Thu, 21 Sep 2017 19:04:02 GMT
Server: Apache/2.4.18 (Ubuntu)
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Location: https://104.236.153.107
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 200 OK
Date: Thu, 21 Sep 2017 19:04:03 GMT
Server: Apache/2.4.18 (Ubuntu)
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Set-Cookie: PHPSESSID=pachujo9i6nbkv61eg422t6am0; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: pll_language=en; expires=Fri, 21-Sep-2018 19:04:04 GMT; Max-Age=31536000; path=/; secure
Link: <https://104.236.153.107/wp-json/>; rel="https://api.w.org/"
Link: <https://104.236.153.107/>; rel=shortlink
Content-Type: text/html; charset=UTF-8

I see that you are touching this conf because you have removed the trailing slash of your redirection.

curl -IkL http://haracoin.com/test
HTTP/1.1 301 Moved Permanently
Date: Thu, 21 Sep 2017 19:05:32 GMT
Server: Apache/2.4.18 (Ubuntu)
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Location: https://haracoin.com/test
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 301 Moved Permanently
Date: Thu, 21 Sep 2017 19:05:33 GMT
Server: Apache/2.4.18 (Ubuntu)
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Location: https://104.236.153.107test
Content-Type: text/html; charset=iso-8859-1

curl: (6) Couldn't resolve host '104.236.153.107test'

So, you have a Redirect, or RewriteRule in your conf or in your .htaccess that is not redirecting properly.

Cheers,
sahsanu

I found a Rewrite rule in /etc/apache2/sites-available/000-default.conf which was:

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.haracoin.com [OR]
RewriteCond %{SERVER_NAME} =haracoin.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

It is in the same location in /etc/apache2/sites-enabled/000-default.conf which was created when I ran certbot, but can’t remember if it was during the self-signed or the letsencrypt proccess

@schoen, users shouldn’t have to do anything special before using Certbot if they have a cert (self-signed or otherwise) that they want to replace with an LE cert.

Fun fact: If Certbot’s Apache plugin is asked to install a cert when the user only has non-TLS vhosts for a domain, we first create a TLS version of the vhost using dummy cert and key directives before the code that installs the cert is run. The actual deployment code just replaces the cert and key directives found in the vhost!

1 Like

Thank you all for the help, but I am still experiencing the same problem. Is there any solutions that you guys can think of to help fix it? I hate to bother you guys about it, but my company wants to release this site to the public today and I need it to not says that the site is secure.

@Azotherian,

Something is performing the redirect; some directive in your conf files, some directive in .htaccess files in your document root or even your own wordpress installation.

1.- Directive in your conf files:

grep -Eri '(Redirect|RewriteRule)' /etc/apache2/

2.- Directive in your .htaccess files (change /tmp by the document root you are using for that domain in the apache conf):

find /tmp -type f -name ".htaccess" -exec grep -EHi '(Redirect|RewriteRule)' {} \;

3.- Log into your WordPress dashboard -> Settings -> General and check what you have in WordPress Address (URL) and Site Address (URL)

Good luck,
sahsanu

This is what comes up when I run grep -Eri '(Redirect|RewriteRule)' /etc/apache2/:

/etc/apache2/mods-available/setenvif.conf:	# The following directive disables redirects on non-GET requests for
/etc/apache2/mods-available/setenvif.conf:	# redirects for folders with DAV methods.
/etc/apache2/mods-available/setenvif.conf:	BrowserMatch "Microsoft Data Access Internet Publishing Provider" 
redirect-carefully
/etc/apache2/mods-available/setenvif.conf:	BrowserMatch "MS FrontPage" redirect-carefully
/etc/apache2/mods-available/setenvif.conf:	BrowserMatch "^WebDrive" redirect-carefully
/etc/apache2/mods-available/setenvif.conf:	BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
/etc/apache2/mods-available/setenvif.conf:	BrowserMatch "^gnome-vfs/1.0" redirect-carefully
/etc/apache2/mods-available/setenvif.conf:	BrowserMatch "^gvfs/1" redirect-carefully
/etc/apache2/mods-available/setenvif.conf:	BrowserMatch "^XML Spy" redirect-carefully
/etc/apache2/mods-available/setenvif.conf:	BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
/etc/apache2/mods-available/setenvif.conf:	BrowserMatch " Konqueror/4" redirect-carefully
/etc/apache2/conf-available/localized-error-pages.conf:# 2) local redirects
/etc/apache2/conf-available/localized-error-pages.conf:# 3) external redirects
/etc/apache2/conf-available/localized-error-pages.conf:# We use Alias to redirect any /error/HTTP_<error>.html.var 
response to
/etc/apache2/sites-available/000-default.conf:	# redirection URLs. In the context of virtual hosts, the ServerName
/etc/apache2/sites-available/000-default.conf:	Redirect permanent "/" "https://haracoin.com/"
/etc/apache2/sites-available/000-default.conf:RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} 
[END,NE,R=permanent]
/etc/apache2/sites-available/000-default-le-ssl.conf:	# redirection URLs. In the context of virtual hosts, the 
ServerName
/etc/apache2/sites-available/000-default-le-ssl.conf:	Redirect permanent "/" "https://104.236.153.107/"

And here is what is in my .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c> 
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

My Wordpress Address (URL) is https://104.236.153.107
and my Site Address(URL) is https://104.236.153.107

If you could help me fix this, that would be great. I could even get you access to the server if you need.

Two things:

1.) This file /etc/apache2/sites-available/000-default-le-ssl.conf has the redirect:

Redirect permanent "/" "https://104.236.153.107/"

For now, comment it:

#Redirect permanent "/" "https://104.236.153.107/"

and restart apache

2.) Your Wordpress site is not configured properly, in those fields should appear your current domain not your ip

https://haracoin.com instead of https://104.236.153.107 in both fields.

Do the changes and try again.

Cheers,
sahsanu

1 Like

Awesome. It works now. Thanks for the help!

Glad it works but as far as I can see, it works partially, it only works if you try to access your site with haracoin.com (http or https, both work) but www.haracoin.com redirects to the ip yet.

Also, did you change your WordPress conf? Because all your links, images, etc, still point to the ip, I don’t use WordPress so I don’t know if you need to perform any other change.

I just noticed that. I updated my site url and wordpress url and I am going through and updating pictures. Thank you for pointing that out and helping me finalize my site!

1 Like

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