To .key and to .pem

At my company, everyday I’ve work with public and private keys. Idea with this key is very simple: I have got one key(private), clients gets another(public). Two keys works only together, a third doesn’t exist.

Where did I used that? For example with https. I need .pem and .key files. PEM includes certificate and KEY include private (usually RSA) key.

But what if client give me another files, like .pfx, crt, csr…? How to live with it?

Below, I give you a little review of this conversion (for more inspiration).

FROM TO How to
.pfx .pem openssl pkcs12 -in file1.pfx -out file2.pem -nokeys
.pfx .key openssl pkcs12 -in file1.pfx -nocerts -nodes -out file2.key
.der .pem openssl x509 -in cert.crt -inform der -outform pem -out cert.pem
.ppk .pem puttygen plik.ppk -O private-openssh -o nowyPlik.pem
.pem .key openssl rsa -outform der -in private.pem -out private.key

Of course this is useless, if you don’t know how and when you can use it. For example, convert from .pfx to .key is possible when in .pfx file exist encoded key. And so on.

If you look closer to this table you can see some patterns. One of them is taking file after “-in” and save new file in file declared after “-out”.

Openssl commands you can run in Linux terminal. Puttygen is application on Windows (you must to install it first).

//image: Designed by Freepik



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s