用中间密钥在nginx上安装SSL证书的问题

我正在尝试在我的Ubuntu服务器上安装SSL证书。 我已经从我的CA购买了证书,并下载了证书本身和一个中间证书。 如此:

我的证书: mydomain.crt
中级证书: GandiStandardSSLCA.pem

我也有(使用openssl

我的私钥(?): mydomain.key
并签署请求: mydomain.csr

我已经将所有这些file upload到我的服务器,并按照指导将我的证书与中间人结合起来:

 cat mydomain.crt GandiStandardSSLCA.pem > mydomain-bundle.crt 

然后,我将以下添加到我的虚拟主机的configuration:

 listen 443 ssl; ssl_certificate /etc/nginx/ssl/mydomain-bundle.crt; ssl_certificate_key /etc/nginx/ssl/mydomain.key; 

但是当我去重新启动nginx我得到这个错误:

*重新启动nginx
*停止nginx nginx [确定]
nginx:[emerg] SSL_CTX_use_PrivateKey_file(“/etc/nginx/ssl/mydomain.key”)失败(SSL:错误:0B080074:x509证书例程:X509_check_private_key:键值不匹配)nginx:configuration文件/etc/nginx/nginx.conftesting失败

任何想法为什么以及如何解决?

你的关键列表是否正确:

 openssl rsa -in /etc/nginx/ssl/mydomain.key 

做钥匙的模数和证书匹配:

 openssl x509 -in mydomain.crt -modulus openssl rsa -in qa.server.key -modulus 

这些数字必须匹配。