Link to home
Start Free TrialLog in
Avatar of beer9
beer9Flag for India

asked on

How to check whether given .pem file is public key or private key

Hello, I have one .pem file and I would like to know whether it is public or private key.. Kindly let me know the openssl command to find whether it is Private or public key. I am having linux box (Ubuntu). Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Bxoz
Bxoz
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of beer9

ASKER

Thanks Bxoz? Do we have openssl command to check whether it is private/public key and also whether it uses a RSA or DSA key algorithm? Thanks!
I don't find such function in openssl, you have all the information if you edit  or display (cat, vi, nano) your .pem files

Why do you want use openssl to do this ?
Avatar of beer9

ASKER

Thanks Bxoz, I have another question. Is it always true that a private key has to be RSA?? I mean it would start with "-----BEGIN RSA PRIVATE KEY-----"? Thanks!
No you can have for example DSA private Key

openssl dsaparam -out dsaparam.pem 2048
openssl gendsa -des3 -out privkey.pem dsaparam.pem

Open in new window

-----BEGIN DSA PRIVATE KEY-----

http://www.openssl.org/docs/HOWTO/keys.txt
Avatar of beer9

ASKER

Thank you! :-)