tags:

views:

1862

answers:

3
+4  Q: 

openssl .pem key

hello every one. How can I create a PEM file from a ssl certificate? These are the files I have available: .crt, server.csr and server.key.

Any ideas?

Thanks

+1  A: 

A pem file contains the certificate and the private key. It depends on the format you certificate/key are in, but probably it's as simple as this:

cat server.crt server.key > server.pem
sth
+5  A: 

Your keys may already be in PEM format, but just named with .crt or .key.

If they begin with -----BEGIN and you can read them in a text editor (they use base64, which is readable in ASCII, not binary format), they are in PEM format.

If the file is in binary, for the server.crt, you would use openssl x509 -inform DER -outform PEM -in server.crt -out server.crt.pem

For server.key, use openssl rsa in place of openssl x509.

The server.key is likely your private key, and the .crt file is the returned, signed, x509 certificate.

If this is for a Web server, and you cannot specify loading a separate private and public key, you may need to concatenate the two files. For this use: cat server.crt server.key > server.includesprivatekey.pem. I would recommend naming files with "includesprivatekey" to help you manage the permissions you keep with this file.

maxwellb
Check the format of the server.key. I only assumed it was RSA. But reading the first line of the file will probably tell you that.
maxwellb
Thanks for going the extra mile. you made my work easier. Great explanation.
Sergio Rodriguez
Glad you got it going.
maxwellb
A: 

Additionally, if you doesnot want ask passphrase, then need to run the following command

openssl rsa -in server.key -out server.key

HTH

rahul