Private key fails openssl verification


I tried to verify my private key using openssl because I’ve been having some difficulties with my web host thinking the certificates are valid. However, the privkey.pem failed the following verification:

openssl x509 -in privkey.pem -text -noout

unable to load certificate
3069641936:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE


I don’t think openssl x509 is supposed to work with private keys. Try openssl rsa -noout -text -in privkey.pem if you want to check if your private key looks sane.


@z0civic, as @pfg said, x509 is not the right switch to check a private key.

To check the health of your private key you could perform this command:

openssl rsa -noout -check -in /etc/letsencrypt/live/yourdomain.tld/privkey.pem

To check whether a private key matches a certificate (both results should be the same):

openssl x509 -noout -modulus -in /etc/letsencrypt/live/yourdomain.tld/cert.pem | openssl md5 
openssl rsa -noout -modulus -in /etc/letsencrypt/live/yourdomain.tld/privkey.pem | openssl md5



md5? are you serious? that one is killed since half an eternity.
I think we should rather get to a better algo like sha512 (my personal favorite)


It’s totally fine in this context, since OP only wanted to check whether the claim his web host made (certificates being invalid) is correct. There are no security implications here.


Thank you! My mistake. Works great once I’m actually using the correct command.

This can be closed now.


Slightly offtopic, but MD5 is much faster too… If I want to check some large binary, I’d be stupid using sha512sum… No, I’m using md5sum :wink: I’m guessing I won’t be getting a spontaneous collision with some arbitrary binaries :stuck_out_tongue:

It’s all in the context @My1 :wink:


It’s probably fairly easy nowadays to modify a binary in a manner that generates a md5 collision. I wouldn’t recommend using md5 in this context if what you’re verifying is that no MITM messed with your binary. If you’re just checking for corruption (network, disk, RAM, whatever) in an otherwise trusted context, md5 works fine.


No, not MITM messing verification of the sorts. That would have security implications, like you said :wink:

Just local binary gigabyte stuff…

The difference is about 140 % for MD5 vs. SHA512: ± 10 seconds vs. ± 14 s. respectively for 3.5 GB :neutral_face:


Yes I’m ;). Here you should understand the reason to use md5 and it is really simple and is nothing about security.

Check this modulus from a cert:

Now compare previous modulus to this one from a private key:

Both seems equal but they are not, just 1 character differs, now hash both strings using md5 and you will get this:

For the first modulus:
(stdin)= 73ff8925ae59af1fc1c1ebfa9b4c8693

For the second one:
(stdin)= 5dab049cd31a9d3e500b5a5e1ef2347e

It’s pretty easy to see that both hashes differ, so, doesn’t matter what kind of hash algorithm you are using because is not about security is just to compare two weird strings in an easy way for a human being ;).