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 changed the header and footer of the PEM file to
-----BEGIN RSA PRIVATE KEY-----
and
-----END RSA PRIVATE KEY-----
Finally, it works!
I'm on Windows 10 and I saved my key with Windows1252 encoding and it worked for me. On another StackOverflow question some people were fixing this with UTF-8 with BOM.
In other words, it may be the file encoding.
Open the key file in Notepad++ and verify the encoding. If it says UTF-8-BOM then change it to UTF-8. Save the file and try again.
Had same issue today, and noticed that this occurs when owner/group of file is not the one running app that reads key. Maybe is your issue too.
Resolution on my side. Change Encoding to UTF8 without BOM
your .key file contains illegal characters. you can check .key file like this:
# file server.key
output "server.key: UTF-8 Unicode (with BOM) text" means it is a plain text, not a key file. The correct output should be "server.key: PEM RSA private key".
use below command to remove illegal characters:
# tail -c +4 server.key > new_server.key
The new_server.key should be correct.
For more detail, you can click here, thanks for the post.