I have a private key file which is in binary format. I need to convert it into .pem
format. I am able to convert using base64 but openssl
is not accepting this file. Is there any other way to convert binary to .pem
which is acceptable by openssl
.
Asked
Active
Viewed 2.0k times
5

Chinna
- 3,930
- 4
- 25
- 55
-
There are 2.7 billion different binary formats for private key files. – President James K. Polk Dec 21 '13 at 13:14
-
Please add information about the precise binary format and your programming environment, or it is impossible to answer this question. – Maarten Bodewes Dec 21 '13 at 14:24
-
3@GregS As your comment is now 14 hours old, is is out of date. The current number is 2.9 billion. – Jumbogram Dec 22 '13 at 03:58
1 Answers
5
Chances are you have a DER encoded key. To convert it you can (likely) do this
openssl rsa -inform der -in <yourfile> -outform pem -out output.pem
Please note that this will only work for unencrypted RSA private keys. If you have a DSA or EC (or PKCS8 formatted) key you'll need to change the command a bit, but you did not provide enough detail for me to narrow it down for you.
(There are also many other private key formats such as PVK, so if this still doesn't work please provide some more information)

Paul Kehrer
- 13,466
- 4
- 40
- 57