October 23, 2009

How do I remove a passphrase from an OpenSSL key?

Have you grown tired of typing your passphrase every time your secured application starts? You can decrypt your key, removing the passphrase requirement, using the rsa or dsa option, depending on the signature algorithm you chose when creating your private key.

If you created an RSA key and it is stored in a standalone file called key.pem, then here’s how to output a decrypted version of the same key to a file called newkey.pem.

# You'll be prompted for your passphrase one last time
openssl rsa -in key.pem -out newkey.pem

Often, you’ll have your private key and public certificate stored in the same file. If they are stored in a file called         mycert.pem, you can construct a decrypted version called newcert.pem in two steps.

# You'll need to type your passphrase once more
openssl rsa -in mycert.pem -out newcert.pem
openssl x509 -in mycert.pem >>newcert.pem

More helpful instructions on OpenSSL certificate, CA and key management can be found here.