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

How to check my .pem certficate's passphrase in a terminal?

· 52CE 我爱测

I had to convert a .pfx certificate into a .pem certificate. However, following a bug I am working on, I am wondering whether the .pem 's passphrase has been set properly. How can I check this easily from a terminal/command line?

问题原文

原帖链接 · Jérôme Verstrynge · CC BY-SA 3.0

I had to convert a .pfx certificate into a .pem certificate. However, following a bug I am working on, I am wondering whether the .pem's passphrase has been set properly.

How can I check this easily from a terminal/command line?

已采纳解答

原帖链接 · Lacek · CC BY-SA 3.0

Actually it's only the key what is protected in the PEM file. You can check the password used to encrypt the key with the following command:

openssl pkey -in /the/pem/file.pem

If it prints the key, then the password you supplied is correct. If it doesn't ask for a password, then it is not protected.

To check it programmatically, use the following:

openssl pkey -in /the/pem/file.pem -passin pass:the_password -noout

and check the $? variable for success. Unfortunately, in this case there is no way to tell whether the key is encrypted or not.

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

资料来源与适用范围

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

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

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