How to convert .pem into .key?

SslApache2Openssl

Ssl Problem Overview


I already have purchased SSL certificate and i have received certificate and a .pem file as a private key? from the supplier; now i need to convert this .pem key into .key for bitnami Redmine Apache web server in order to make it work.

How do I go about doing this what what program or commands to do this? I am a newbie in terms of using Openssl etc to do this.

Any advice would be much appreciated!

Thank you.

Ssl Solutions


Solution 1 - Ssl

I assume you want the DER encoded version of your PEM private key.

openssl rsa -outform der -in private.pem -out private.key

Solution 2 - Ssl

openssl rsa -in privkey.pem -out private.key does the job.

Solution 3 - Ssl

openssl x509 -outform der -in your-cert.pem -out your-cert.crt

Solution 4 - Ssl

CA's don't ask for your private keys! They only asks for CSR to issue a certificate for you.

If they have your private key, it's possible that your SSL certificate will be compromised and end up being revoked.

Your .key file is generated during CSR generation and, most probably, it's somewhere on your PC where you generated the CSR.

That's why private key is called "Private" - because nobody can have that file except you.

Solution 5 - Ssl

If you're looking for a file to use in httpd-ssl.conf as a value for SSLCertificateKeyFile, a PEM file should work just fine.

See this SO question/answer for more details on the SSL options in that file.

https://stackoverflow.com/questions/4814851/why-is-sslcertificatekeyfile-needed-for-apache

Solution 6 - Ssl

just as a .crt file is in .pem format, a .key file is also stored in .pem format. Assuming that the cert is the only thing in the .crt file (there may be root certs in there), you can just change the name to .pem. The same goes for a .key file. Which means of course that you can rename the .pem file to .key.

Which makes gtrig's answer the correct one. I just thought I'd explain why.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1644587View Question on Stackoverflow
Solution 1 - SslCamille G.View Answer on Stackoverflow
Solution 2 - SslJAFPView Answer on Stackoverflow
Solution 3 - SslBogdan UstyakView Answer on Stackoverflow
Solution 4 - SslThe WhispererView Answer on Stackoverflow
Solution 5 - SslgtrigView Answer on Stackoverflow
Solution 6 - SslGerard ONeillView Answer on Stackoverflow