在Nginx错误日志中,"SSL_CTX_use_PrivateKey_file""获取密码错误的问题"是什么意思?

Ale*_*x D 35 ssl https openssl nginx private-key

我正在尝试在Nginx上设置SSL.它不起作用,我在错误日志中收到以下错误,这是从编译nginx的OpenSSL库中传递出来的.我不知道那个库是什么,但它是nginx的0.8.54版本,我在Ubuntu Linux上使用apt-get安装它.

2012/02/21 07:06:33 [emerg] 4071#0: 
SSL_CTX_use_PrivateKey_file("/exequias/certs/exequias.com.key") failed (SSL: 
error:0906406D:PEM routines:PEM_def_callback:problems getting password error:
0906A068:PEM routines:PEM_do_header:bad password read error:140B0009:SSL routines:
SSL_CTX_use_PrivateKey_file:PEM lib)
Run Code Online (Sandbox Code Playgroud)

我确保私钥文件的文件权限不会阻止nginx读取它.它是一个生成的RSA私钥openssl rsa.

可能导致这种情况的任何想法?

Rav*_*ila 55

删除密钥密码短语:

openssl rsa -in key.pem -out newkey.pem
Run Code Online (Sandbox Code Playgroud)

如果证书和密钥在一起:

openssl rsa -in mycert.pem -out newcert.pem
openssl x509 -in mycert.pem >>newcert.pem
Run Code Online (Sandbox Code Playgroud)

资料来源:http://www.madboa.com/geek/openssl/#key-removepass

  • 非常感谢!我在R'lyeh.你救了我的理智. (2认同)
  • 不客气:-) 我听到了。我写这个答案已经两年了,现在我一点都不记得了 :D #insanityrealized (2认同)

Ale*_*x D 20

我明白了...与nginx一起使用的私钥文件必须没有密码.我删除了密码并且它有效.


sud*_*doz 13

因为您使用密码短语生成.crt文件,所以您需要为Nginx conf中的.key和.crt文件指定相同的密码短语

server {
    ssl_password_file /path-to-your-passphrase/ssl.pass;
}
Run Code Online (Sandbox Code Playgroud)

Nginx Doc

或者,如果您不需要证书文件的密码,只需使用ssh-keygen工具生成如下文件:

ssh-keygen -t rsa
Run Code Online (Sandbox Code Playgroud)