Issues with SSL and "unable to get local issuer certificate"

Hi,

I’m on QNAP and use home-assistant docker image. While I’m having no issues with normal browsing or iOS app but when trying to configure appdaemon i had a problem that I cannot solve by myself.

I use the Let’s Encrypt certificate managed by Qnap SSL Utility and if i connect with curl to qnap homepage with curl (for example) all is working fine:
curl -v https://[FQDN]
Rebuilt URL to: https://[FQDN]
Trying [IP]...
Connected to [FQDN] ([IP]) port 443 (#0)
ALPN, offering http/1.1
Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
successfully set certificate verify locations:
CAfile: none
CApath: /etc/ssl/certs
TLSv1.2 (OUT), TLS header, Certificate Status (22):
TLSv1.2 (OUT), TLS handshake, Client hello (1):
TLSv1.2 (IN), TLS handshake, Server hello (2):
TLSv1.2 (IN), TLS handshake, Certificate (11):
TLSv1.2 (IN), TLS handshake, Server key exchange (12):
TLSv1.2 (IN), TLS handshake, Server finished (14):
TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
TLSv1.2 (OUT), TLS change cipher, Client hello (1):
TLSv1.2 (OUT), TLS handshake, Finished (20):
TLSv1.2 (IN), TLS change cipher, Client hello (1):
TLSv1.2 (IN), TLS handshake, Finished (20):
SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
ALPN, server accepted to use http/1.1
Server certificate:
subject: CN=[FQDN]
start date: 2018-08-14 13:33:55 GMT
expire date: 2018-11-12 13:33:55 GMT
subjectAltName: [FQDN] matched
issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
SSL certificate verify ok.
GET / HTTP/1.1
Host: [FQDN]
User-Agent: curl/7.43.0
Accept: */*
HTTP/1.1 200 OK
Date: Mon, 08 Oct 2018 16:17:27 GMT
Server: http server 1.0
X-Frame-Options: SAMEORIGIN
Content-type: text/html; charset=UTF-8
Last-modified: Wed, 14 Mar 2018 21:49:47 GMT
Accept-Ranges: bytes
Content-length: 580
Vary: Accept-Encoding

<html>
<head>
</head>
<body>
</body>
</html>
Connection #0 to host [FQDN] left intact

while doing the same on home-assistant gives error:
[~] # curl -v https://[FQDN]:8123
Rebuilt URL to: https://[FQDN]:8123/
Trying [IP]...
Connected to [FQDN] ([IP]) port 8123 (#0)
ALPN, offering http/1.1
Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
successfully set certificate verify locations:
CAfile: none
CApath: /etc/ssl/certs
TLSv1.2 (OUT), TLS header, Certificate Status (22):
TLSv1.2 (OUT), TLS handshake, Client hello (1):
TLSv1.2 (IN), TLS handshake, Server hello (2):
TLSv1.2 (IN), TLS handshake, Certificate (11):
TLSv1.2 (OUT), TLS alert, Server hello (2):
SSL certificate problem: unable to get local issuer certificate
Closing connection 0
TLSv1.2 (OUT), TLS alert, Client hello (1):
curl: (60) SSL certificate problem: unable to get local issuer certificate
more details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

No error from browsers
immagine

The result is that I cannot connect appdaemon with home-assistant…
Please help me

1 Like

Do you use port forwarding on your router ?

Hi @galoz11,

Thank you for your answer. Yes, and it’s not a connection issue since the docker images (home-assistant and appdaemon) are on the same server.

@fakezeta, please confirm port 80 to port 80 is forward open.
this port is used for Let’s Encrypt certificate check.

Yes, it’s open but does not redirect to home-assistant container but to qnap http server. The certificate is the same obviously since the FQDN is the same.

for future help:

fixed merging cert and intermediate.pem file from /mnt/HDA_ROOT/.config/QcloudSSLCertificate/cert directory in one file with
cat cert intermediate.pem > full
and using full in ssl_certificate config option.

1 Like