大网数据广告活动
服务器运维问答

How to configure nginx + ssl with an encrypted key in .pem format

· 52CE 我爱测

I would like to set up ssl for an existing nginx server. I got handed both a certificate and the corresponding (encrypted) private key. Both are in .pem format (each in its own file). About all tutorials (e.g. 1 ) I found assume …

问题原文

原帖链接 · Zappl · CC BY-SA 4.0

I would like to set up ssl for an existing nginx server. I got handed both a certificate and the corresponding (encrypted) private key. Both are in .pem format (each in its own file).

About all tutorials (e.g. 1) I found assume a key in the .key format.

When I configure + start nginx the certificate seems to get accepted so far. However I'm asked for a PEM pass phrase for the private key file.

Am I correct in the assumption that my only options are to either set up a nginx "ssl_password_file" with the pass phrase or use openssl/libressl to convert the .pem file containing the encrypted key to an unencrypted .key file like this?

How else should I handle an encrypted private key in .pem format?

社区高分解答

原帖链接 · Richard Smith · CC BY-SA 4.0

You've pretty much answered your own question.

Don't be confused by file extensions. The private key, whether password protected or not, is usually in PEM format. Often .pem is used for the certificate file, so .key is chosen for the corresponding private key. But the file extension is irrelevant.

So you have three options:

  • Manually boot the server and provide the password at the console. This is probably the most secure option but also impractical for many situations.
  • Provide a password file using ssl_password_file
  • Permanently remove the password protection using openssl

For example, to remove the password from a private key:

openssl rsa -in original.key -out plain.key

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-10-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。