Thanks!

On Thu, Jun 3, 2010 at 4:54 PM, Dr. Stephen Henson <st...@openssl.org>wrote:

> On Thu, Jun 03, 2010, Mounir IDRASSI wrote:
>
> > Hi,
> >
> > One simple and efficient method to distinguish between PEM and DER
> encoding
> > for a CRL or a certificate is to read the first byte : if it's equal to
> > 0x30 then this DER (this is the start of an ASN.1 Sequence) , otherwise
> it
> > is PEM encoded.
> > This works ONLY if you are sure that the given file is either PEM or DER
> > encoded and that the encoded object is an ASN.1 Sequence.
> >
>
> Since the 0x30 byte correspond to the ASCII character '0' there is a slight
> chance this will fail if the file is PEM format and contains text
> before the PEM headers. This can be further reduced by checking the length
> field following the SEQUENCE tag.
>
> Steve.
> --
> Dr Stephen N. Henson. OpenSSL project core developer.
> Commercial tech support now available see: http://www.openssl.org
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majord...@openssl.org
>

Reply via email to