Hello,
I am using Linux.
I am trying to print the subjectAltName present in the certificate, but
i am seeing crash in /lib/libcrypto.so.6
core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0 0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
(gdb) bt
#0 0x058b8a03 in OBJ_cmp () from /lib/libcrypto.so.6
#1 0x0593a786 in X509v3_get_ext_by_OBJ () from /lib/libcrypto.so.6
#2 0x0593a7ce in X509v3_get_ext_by_NID () from /lib/libcrypto.so.6
#3 0x08048870 in find_root_cert (in=0x9445a72 "", len=1002) at
find_root.c:37
#4 0x080489af in main () at find_root.c:65
Help me to solve this issue. Please guide, if any other alternative to
method to achieve the same
Please find the code used below.
Thanks and Regards
Naveen
/************ Start code ***************/int find_root_cert(char
*in,int len)
{
X509 *cert1=NULL;
X509_NAME *name;
char *buffer; X509_EXTENSION *ext=NULL;
char *test;
int pos=0,nid;
cert1=d2i_X509(NULL,&in,len);
printf("\n cert=%x ", cert1);
name=X509_get_subject_name(cert1);
buffer=X509_NAME_oneline(name, 0, 0);
if(strstr(buffer,"CN=kdc.globaledgesoft.com")==NULL)
return -1;
else
{ * nid=OBJ_sn2nid("subjectAltName");
pos=X509v3_get_ext_by_NID (cert1,OBJ_sn2nid("subjectAltName"), -1);
ext=X509v3_get_ext(cert1,pos);
if(ext!=NULL){
test=d2i_ASN1_IA5STRING(&ext->value->data,NULL,0);
printf("\n test =%s ", test);*
}
return 0;
}
}
int main(int argc, char **argv)
{
const unsigned char *in ;
int len,size,ret;
X509 *cert1=NULL;
X509 *cert2=NULL;
FILE *fp;
struct stat st;
fp = fopen("kdc.cer","r");
stat ( (const char *)"kdc.cer",&st);
size = st.st_size;
in=(unsigned char *)malloc(++size);
printf("\n length = %d ",size);
len=fread(in,1,size,fp);
fclose(fp);
printf("\n Len =%d",len);
printf("\n cert=%x ", cert1);
if(find_root_cert(in,len)==0)
printf("\n This is the Root\n");
else
printf("\n No match was found \n");
}
/************* End ************/
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org