Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2011-02-16
6
595 Views
Last Modified: 2012-05-11
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!
0
Comment
Question by:beer9
  • 3
  • 3
6 Comments
 
LVL 6

Accepted Solution

by:
Bxoz earned 500 total points
ID: 34910672
Do a cat on your different .pem
the private key should be like that
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
 
0
 

Author Comment

by:beer9
ID: 34910978
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!
0
 
LVL 6

Expert Comment

by:Bxoz
ID: 34911362
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 ?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:beer9
ID: 34944290
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!
0
 
LVL 6

Expert Comment

by:Bxoz
ID: 34946013
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
0
 

Author Closing Comment

by:beer9
ID: 34987029
Thank you! :-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We've all had that page pop up telling us there is a problem with the certificate and some of us continue on anyways and others run away to a safer competing site.  But what to do when you get the error - is it your problem or theirs?  What can you …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question