Gal*_*lou 84 ssl openssl key certificate nginx
我无法设置SSL.我用谷歌搜索了一些解决方案,但没有一个能为我工作.我需要一些帮助...
这是我尝试重新启动nginx时出现的错误:
root@s17925268:~# service nginx restart
Restarting nginx: nginx: [emerg] SSL_CTX_use_PrivateKey_file("/etc/nginx/conf.d/ssl/ssl.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
nginx: configuration file /etc/nginx/nginx.conf test failed
Run Code Online (Sandbox Code Playgroud)
我的证书来自StartSSL,有效期为1年.
这是我测试的内容:
我还检查了模数,我得到了密钥和证书的不同模数.
谢谢您的帮助.:)
Vyn*_*nce 153
一旦你确定他们不匹配,你仍然有一个问题 - 如何处理它.通常,证书可能仅仅是错误地组装.当CA签署您的证书时,他们会向您发送一个类似的块
-----BEGIN CERTIFICATE-----
MIIAA-and-a-buncha-nonsense-that-is-your-certificate
-and-a-buncha-nonsense-that-is-your-certificate-and-
a-buncha-nonsense-that-is-your-certificate-and-a-bun
cha-nonsense-that-is-your-certificate-and-a-buncha-n
onsense-that-is-your-certificate-AA+
-----END CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)
他们还会向您发送一个捆绑(通常是两个证书),代表他们授予您证书的权限.这看起来像
-----BEGIN CERTIFICATE-----
MIICC-this-is-the-certificate-that-signed-your-request
-this-is-the-certificate-that-signed-your-request-this
-is-the-certificate-that-signed-your-request-this-is-t
he-certificate-that-signed-your-request-this-is-the-ce
rtificate-that-signed-your-request-A
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICC-this-is-the-certificate-that-signed-for-that-one
-this-is-the-certificate-that-signed-for-that-one-this
-is-the-certificate-that-signed-for-that-one-this-is-t
he-certificate-that-signed-for-that-one-this-is-the-ce
rtificate-that-signed-for-that-one-this-is-the-certifi
cate-that-signed-for-that-one-AA
-----END CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)
除了不幸的是,他们的标签不会那么清楚.
通常的做法是将这些全部捆绑到一个文件中 - 您的证书,然后是签名证书.但由于它们不容易区分,有时会发生某人意外地将它们置于另一个顺序 - 签署证书,然后是最终证书 - 而没有注意到.在这种情况下,您的证书将与您的密钥不匹配.
您可以通过运行来测试以查看证书认为它代表的内容
openssl x509 -noout -text -in yourcert.cert
Run Code Online (Sandbox Code Playgroud)
在顶部附近,你应该看到"主题:",然后看起来像你的数据.如果它看起来像你的CA,你的包可能是错误的顺序; 您可以尝试进行备份,然后将最后一个证书移到开头,希望这是您的证书.
如果这不起作用,您可能只需要重新颁发证书.当我创建CSR时,我喜欢清楚标记它的服务器(而不仅仅是ssl.key或server.key)并使用名称中的日期复制它,例如mydomain.20150306.key等.他们的私钥和公钥对不太可能与另一套混在一起.
dev*_*v0z 61
检查公钥的MD5哈希,以确保它与私钥中的内容匹配
openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in privateKey.key | openssl md5
Man*_*ill 30
我有这个问题,因为我是以错误的顺序添加捆绑和证书,所以这可能会帮助其他人.
之前(这是错误的):
__CODE__
之后(这是对的)
__CODE__
并且请不要忘记更新相应的conf(ssl_certificate现在必须指向链接的crt)as
cat ca_bundle.crt certificate.crt > bundle_chained.crt
Run Code Online (Sandbox Code Playgroud)
如果服务器证书和软件包的连接顺序错误,则nginx将无法启动并显示错误消息:
cat certificate.crt ca_bundle.crt > bundle_chained.crt
Run Code Online (Sandbox Code Playgroud)
如果发生这种情况并且您正在使用Let的加密/ certbot,原因很可能是您使用chain.pem
而不是fullchain.pem
.
它应该是这样的:
ssl_certificate /etc/certbot/live/example.com/fullchain.pem;
ssl_certificate_key /etc/certbot/live/example.com/privkey.pem;
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,最终通过更改证书文件中 pem 块的顺序解决了它。
cert 块应该放在文件的开头,然后是中间块,然后是根块。
我通过比较有问题的证书文件和工作证书文件来意识到这个问题。
归档时间: |
|
查看次数: |
103998 次 |
最近记录: |