I have a .key file which is PEM formatted private key file. I didn\'t make this file but I got this from somewhere.
I wanted to see its MD5 hash with openssl tool li
> I have a .key file which is PEM formatted private key file.
> ...
> Here's some asn1parse of the .key file...
That it appears OK with asn1parse
leads me to believe its not PEM encoded.
Is there anything more I can try?
Because it appears to be ASN.1, try:
$ openssl rsa -in server.key -inform DER -modulus -noout
Notice the -inform DER
to switch between encodings.
In our case what caused the issue is that the private key we were trying to use was encrypted with a passphrase.
We had to decrypt the private key using ssh-keygen -p
before we could use the private key with the openssl command line tool.
None of the other answers seemed correct in my case, however I found the real answer here
My id_rsa
file was already in PEM format, I just needed to add the .pem
extension to the filename.
Thanks to
The possible options to the openssl rsa -inform
parameter are one of: PEM
DER
A
PEM
encoded file is a plain-text encoding that looks something like:-----BEGIN RSA PRIVATE KEY----- MIGrAgEAAiEA0tlSKz5Iauj6ud3helAf5GguXeLUeFFTgHrpC3b2O20CAwEAAQIh ALeEtAIzebCkC+bO+rwNFVORb0bA9xN2n5dyTw/Ba285AhEA9FFDtx4VAxMVB2GU QfJ/2wIRANzuXKda/nRXIyRw1ArE2FcCECYhGKRXeYgFTl7ch7rTEckCEQDTMShw 8pL7M7DsTM7l3HXRAhAhIMYKQawc+Y7MNE4kQWYe -----END RSA PRIVATE KEY-----
While
DER
is a binary encoding format.
May be the private key itself is not present in the file.I was also faced the same issue but the problem is that there is no private key present in the file.
Remove any whitespace at the start of the .key file.
openssl genrsa -out privateKey.pem 4096
openssl req -new -x509 -nodes -days 3600 -key privateKey.pem -out caKey.pem