Hi,
can U help me out ?
I am using the code ..but for .der type of file it is giving me a null pointer ..
but this code is working fine for .pem type ..
 
here is the code I am using ..
main()
{
    string     sCerrtPath="c:/mycert.der";
    char    buf[256];
    memset(buf,0,256);
 
     X509 * pCert=NULL;
     FILE *fp=fopen(sCertPath.c_str(),"rb");
     if(!fp)
     {   
          cout<<" file not found"<<endl;
          return 0;
     }
 
     pCert=PEM_read_X509(fp,NULL,0,NULL);
 
     if(pCert==NULL)
               d2i_X509_fp(fp,&pCert);  
 
     fclose(fp);
 
     if(pCert==NULL)
     {
          cerr << "ERROR: unknown format certificate" << endl;
          return 0;
     }
 
     X509_NAME_oneline(X509_get_subject_name(pCert), buf, 256);
     cout<<buf;
 
     return 1;
}
regards
Ratan
 

Reply via email to