Hi Kyle,
Thanks a ton for the quick reply buddy :)
When we debug our application in visual studio, we see that both "Extension"
and "Extension->value" are not NULL. But "Extension->value->data" seems to be
NULL or corrupted, causing our application to crash.
I am trying these options for debugging the problem :
> make sure the X509 certificate we are using is a valid one, containing the
> extension we are looking for, because "Certificate->valid" is set to 0 for
> our certificate.
> debug through the openssl function X509_get_ext( ) in visual studio by
> attaching the openssl source, to see why "Extension->value->data" is not
> being set correctly.
> also try using some older openssl version instead of the current 0.9.8 d we
> are currently using.
I will update again after trying these options.
I suspect something being wrong in this certificate itself, may be it does not
comply to the X509 certificate format. Can you please confirm that the
certificate we are using is a valid x509 certificate ?
This is the certificate we are using :
static unsigned char *LETestDefaultKey = {
"-----BEGIN RSA PRIVATE KEY-----\r\n"
"MIIBPAIBAAJBAM6ss7cWYg0Yf7Ot6PkdWBtQ0Pp89YO/2rG0K8iAJW5AY399hh/s\r\n"
"VjiIfPZpqCwqJka/2r23jzZJfW8X19nTiqECAwEAAQJATBeXv0P1a77mXYAdM4LT\r\n"
"SpNRrbfOKOi9GworyJEtts5Cn153ROK3750NHrOeaXbkFl89/UD0oMsO22TnF+Ol\r\n"
"lQIhAO0gkTZggugyZ7HDQihy/7EVAgK9rg7SPc5JnyZITW5bAiEA3x+q4AZDXUHW\r\n"
"26W7BlZoedPy6Mo5wWNb/gN9x/T987MCIQCt8TfUFZOxVFgwU7USCtl5QpnI/O7T\r\n"
"PHHOAr9Vy6/RBQIhAJPO76y+mWuzDPmu/YmCPm3OWZGbPc1929gXSgDnrD//AiEA\r\n"
"vwlwVtb26OSBJX47M+MZeWsiD3GVydtRdcL9+Xy0XEw=\r\n"
"-----END RSA PRIVATE KEY-----\r\n"
};
static unsigned char *LETestDefaultCert = {
"-----BEGIN CERTIFICATE-----\r\n"
"MIIBojCCAUygAwIBAgIBMzANBgkqhkiG9w0BAQQFADAqMQswCQYDVQQGEwJVUzEb\r\n"
"MBkGA1UEAxMSTm92ZWxsIE5TdXJlIEF1ZGl0MB4XDTA1MTAxMTE3NDEyOFoXDTE1\r\n"
"MTAwOTE3NDEyOFowJjELMAkGA1UEBhMCVVMxFzAVBgNVBAMTDlNlY3VyZUxvZ2lu\r\n"
"U1NPMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAM6ss7cWYg0Yf7Ot6PkdWBtQ0Pp8\r\n"
"9YO/2rG0K8iAJW5AY399hh/sVjiIfPZpqCwqJka/2r23jzZJfW8X19nTiqECAwEA\r\n"
"AaNhMF8wDgYDVR0PAQH/BAQDAgWgMBgGA1UdEQQRMA+BDWFyZ2xAYmxhaC5jb20w\r\n"
"EQYJYIZIAYb4QgEBBAQDAgWgMCAGDGCGSAGG+DcBglsKAQQQFg5TZWN1cmVMb2dp\r\n"
"blNTTzANBgkqhkiG9w0BAQQFAANBABaOsowc+4encEksW5w1v1dHg7DNdBbQJHct\r\n"
"JSNfzPfE8igm617Ggsfrb0nkc50mdlyugkfZC/dX+sx4vtQk1Ok=\r\n"
"-----END CERTIFICATE-----\r\n"
};
Looking forward for your reply... have a wonderful day ahead !!!
Regards,
Sanjay
>>> Kyle Hamilton <[email protected]> 11/24/2009 4:56 AM >>>
Are you checking to make sure that there *is* data in that extension?
Or that the extension value even exists?
if (NULL == Extension->value) assert("Extension->value NULL");
if (NULL == Extension->value->data) assert ("Extension->value->data NULL");
OrgPtr=Extension->value->data;
-Kyle H
On Fri, Nov 20, 2009 at 3:50 AM, Sanjay Bhat <[email protected]> wrote:
>
> Hi,
>
> Our application running in windows 2008 64-bit platform crashes when we try
> to access the data member of X509_EXTENSION returned by X509_get_ext().
>
> We are using 0.9.8d version of openssl compiled for windows 64 bit
> platform.
>
> We are clueless why this is happening and are badly stuck with this. Please
> help us.
>
> Here is the code snippet of our application with the point of crash in bold
> :
>
> BOOL GetX509ObjectString(X509 *Certificate, unsigned char *ASN1, unsigned
> char *Short, unsigned char *Description, unsigned char *Buffer, unsigned
> long BufSize)
> {
> X509_EXTENSION *Extension;
> int nid;
> int Position;
> ASN1_STRING *Value;
> unsigned char *OrgPtr;
>
> if (!Buffer) {
> return(FALSE);
> }
> Buffer[0]='\0';
>
> nid = OBJ_create(ASN1, Short, Description);
> Position=X509_get_ext_by_NID(Certificate, nid, -1);
> if (Position==-1) {
> return(FALSE);
> }
>
> Extension=X509_get_ext(Certificate, Position);
> if (!Extension) {
> return(FALSE);
> }
>
> /* The M_d2i function alters the pointer, so keep a copy */
> OrgPtr=Extension->value->data; //This is the point of crash. Referencing
> data member seems to be causing the crash
> Value=M_d2i_ASN1_IA5STRING(NULL, &(Extension->value->data),
> Extension->value->length);
> Extension->value->data=OrgPtr;
> strncpy(Buffer, Value->data, min(Value->length+1, BufSize));
> Buffer[min(Value->length+1, BufSize)-1]='\0';
> ASN1_STRING_free(Value);
> return(TRUE);
> }
>
> Appreciate any kind of help on this is greatly appreciated.
>
> Thanks & Regards,
> Sanjay.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]