我的 nginx 服务器带有 StartSSL 免费证书,该证书即将过期。我想更新它。
openssl req -new -sha256 -nodes -days 365 -newkey rsa:2048 -keyout ssl.key -out ssl.csr
我在其中输入生成证书所需的信息。我将此 CSR 粘贴到网站中,并成功获得了域和主域上的 2 个子域的签名证书。
在我加载证书服务器后输出这个错误:
feb 05 17:46:19 systemd[1]: Unit nginx.service entered failed state.
feb 05 17:47:13 nginx[4514]: nginx: [emerg] SSL_CTX_use_PrivateKey_file("/etc/nginx/ssl/nginx.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
feb 05 17:47:13 nginx[4514]: nginx: configuration file /etc/nginx/nginx.conf test failed
feb 05 17:47:13 systemd[1]: nginx.service: control process exited, code=exited status=1
feb 05 17:47:13 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
我用这些命令测试了模数:
openssl x509 -noout -modulus -in nginx.crt | openssl md5
openssl rsa -noout -modulus -in nginx.key | openssl md5
openssl req -noout -modulus -in ssl.csr | openssl md5
并且它们匹配。
StartSSL 提供带有中间证书的证书包。我发现如果它们的顺序不正确,它可能会失败,所以我尝试将它们作为第一个证书,但没有成功。
编辑:我尝试在另一台使用 nginx 1.9.3 的服务器上进行 key 和证书,它正在运行。所以证书没问题,但服务器不行。
请在创建 bundle 时检查证书序列。它应该按以下顺序:
服务器证书
中级证书
根证书
这可能是错误背后的原因。
我是一名优秀的程序员,十分优秀!