[openssl-users] get type of PEM data

Viktor Dukhovni openssl-users at dukhovni.org
Wed Mar 28 16:59:45 UTC 2018



> On Mar 28, 2018, at 11:02 AM, Jordan Brown <openssl at jordan.maileater.net> wrote:
> 
> I'm finding that it would be helpful to have a function that would, given PEM data (in memory or in a file) return an indication of what kind of object it represents:  a certificate, a private key, et cetera.  The ideal function would basically tell me which PEM_read_bio_foobar function I would use to read the PEM data (and thus what C type it represents).  It would lump all private key formats into one type, since PEM_read_PrivateKey would work on all of them and return an EVP_PKEY.
> 
> Does such a function already exist?  Any thoughts?

PEM_read_bio() reads a generic PEM object.  The header name
can then be compared with the various PEM_STRING_... constants.

OpenSSL can already read keys in a general way.  See, 
PEM_read_bio_PrivateKey() returning an EVP_PKEY.  So you
don't need to reinvent this.

-- 
	Viktor.



More information about the openssl-users mailing list