nginx ssl配置问题(curl 60错误)
通过acme.sh工具给网站配置了ssl,按照流程配置成功后,使用浏览器可以正常访问,但使用curl进行访问时,出现如下错误:
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
由于浏览器能够访问成功,就主观认为是系统curl和系统证书的问题。
找到了这里,尝试了各种方法都不行。
最终找到这个网站对自己网站的ssl进行测试,结果是:
****.com is misconfigured. This is the chain it should be using.
于是怀疑是自己nginx配置有问题,查看网站给出的证书文件(chain),比自己配置的多了一部分。
网站上的有两个CERTIFICATE
段,而acme.sh生成的只有一个。直接从whatsmychaincert
网站下载fallchain证书。
在服务器上重新配置,并重启nginx,curl就可以访问了。
对比nginx和apache的配置:
acme.sh --install-cert -d example.com \
--cert-file /path/to/certfile/in/apache/cert.pem \
--key-file /path/to/keyfile/in/apache/key.pem \
--fullchain-file /path/to/fullchain/certfile/apache/fullchain.pem \
--reloadcmd "service apache2 force-reload"
acme.sh --install-cert -d example.com \
--key-file /path/to/keyfile/in/nginx/key.pem \
--fullchain-file /path/to/fullchain/nginx/cert.pem \
--reloadcmd "service nginx force-reload"
可以看到apache多配置了一个 --cert-file 参数,而nginx只配置了 --fullchain-file ,仔细看了一下nginx的证书安装命令,原来是安装了cert文件,忘记安装fullchain文件了。
大意了。。。
明明参数是--fullchain-file
为啥文件名要是cert.pem