Nginx not serving intermediate certificate

2019-06-04 19:04发布

问题:

I am trying to install an ssl certificate on Nginx (laravel forge actually). I have concatenated the certificate with the intermediate and I don't get any errors in the Nginx error log. However it is not trusted in mobile chrome - only desktops.

Looking at Qualys ssl test, it's says that the Chain is incomplete. I don't see how though.

Here's my Nginx config

server {
listen 80;
server_name **********.com;
return 301 https://**********.com$request_uri;
}

server {
listen 443 ssl;
server_name **********.com;
root /home/forge/**********.com/public;

# FORGE SSL (DO NOT REMOVE!)
ssl on;
ssl_certificate /etc/nginx/ssl/**********.com/1086/server.pem;
ssl_certificate_key /etc/nginx/ssl/**********.com/1086/server.key;

index index.html index.htm index.php;

charset utf-8;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

access_log off;
error_log  /var/log/nginx/**********.com-error.log error;

error_page 404 /index.php;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

location ~ /\.ht {
    deny all;
}
}

Can any one help? I have been pulling my hair out for days.

回答1:

Looking at Qualys ssl test, it's says that the Chain is incomplete. I don't see how though...

It looks like you are sending the wrong intermediate:

$ openssl s_client -connect cauterypens.com:443
CONNECTED(00000003)
depth=0 C = GB, OU = Domain Control Validated, CN = cauterypens.com
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 C = GB, OU = Domain Control Validated, CN = cauterypens.com
verify error:num=27:certificate not trusted
verify return:1
depth=0 C = GB, OU = Domain Control Validated, CN = cauterypens.com
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
 0 s:/C=GB/OU=Domain Control Validated/CN=cauterypens.com
   i:/C=BE/O=GlobalSign nv-sa/CN=AlphaSSL CA - SHA256 - G2
 1 s:/O=AlphaSSL/CN=AlphaSSL CA - G2
   i:/C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA
 ...

The subject of certificate 0 is CN=cauterypens.com. The issuer of certificate 0 is CN=AlphaSSL CA - SHA256 - G2.

The intermediate certificate should be the next in the chain. However, rather than sending CN=AlphaSSL CA - SHA256 - G2, you are sending CN=AlphaSSL CA - G2. Notice the lack of SHA256 in the name.

To fix this, you should fetch AlphaSSL CA - SHA256 - G2 from Download GlobalSign Root and Intermediate Certificate. It has thumprint thumbprint ae:bf:32:c3:c8:32:c7:d7:bc:55:99:b1:aa:05:fb:6c:f4:d9:29:4c.


Related: the CA is CN=GlobalSign Root CA. That's the GlobalSign Root R1 download. Download it and save it to a file (its name is Root-R1.crt). Its already in a PEM encoding. Then, you should be able to verify the chain with:

$ openssl s_client -connect cauterypens.com:443 -CAfile Root-R1.crt
...
Verify OK (0)

If it does not verify, then you have other troubles. Fix the problems before proceeding.



标签: ssl nginx chain