4

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?

1 Answer 1

12

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.