Your alleged DER encoded certificate is wrong. The first two bytes should be 
0x30 (the ASN.1 SEQUENCE tag) followed by 0x82 (meaning the next two bytes are 
the length).

This question probably belongs on the OpenSSL-users list, as it doe not pertain 
to development of the OpenSSL library itself. 

> On Oct 25, 2013, at 5:15 AM, "Elluru, Krishna" <[email protected]> 
> wrote:
> 
> HI,
> for some testing, I have generated a .der format file and created a hex dump, 
> and in the code I have put the contents of this hexdump in a char array and 
> passed to this function.
> 
> int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char 
> *d). I am using openssl 1.0.1e source code.
> 
> I see below errors when I do it.
> 
> err number is 155 at line 142 file src/openssl/crypto/asn1/asn1_lib.c   -- 
> ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG) -- plength 1182, omax 33, 
> omax-(p-*pp) - 29
> err number is 102 at line 1307 file src/openssl/crypto/asn1/tasn_dec.c -- 
> err number is 58 at line 382 file src/openssl/crypto/asn1/tasn_dec.c -- 
> err number is 13 at line 516 file src/openssl/ssl/ssl_rsa.c func 172 
> 
> my array size is 1186 bytes, which is same as .der file also. here is my code 
> snippet. let me know, if I am doing something wrong. I checked the archive 
> for similar cases already.
> <snippet>
> const unsigned char cert[]={
>     0x82, 0x04, 0x9e, 0x30, 0x82, 0x03, 0x86, 0xa0, 0x03, 0x02, 0x02, 0x02, 
> 0x04, 0x52,
>     0x56, 0x7f, 0x93, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 
> 0x0d, 0x01, 0x01, 0x0b, …..
>     …..};
> const unsigned char *tx = cert;
> 
> ….(all library init is done, and ctx is created correctly)
> 
> result_ssl = SSL_CTX_use_certificate_ASN1(ctx, length, tx);
> <snippet>
> 
> Thanks
> Krishna Mohan
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [email protected]

Reply via email to