Hi All,
I am using the following code to load a DER encoded certificate. In case of
PEM the certificate gets loaded fine but the d2i_X509_fp function always
return me  NULL
       FILE * fPointer;
        X509 *x509Cert = NULL;
        fPointer = fopen(szPath,"rb");
                
        if(fPointer == NULL)
        {
                cout<<"No certifcate found at"<<szPath<<endl;
                return 0;
        }

        
        //If path is valid then we check if there is 
        //a certificate on the path that can be loaded
        
        x509Cert = PEM_read_X509(fPointer, NULL, NULL, NULL);
        //PEM_read_X509(fPointer, &x509Cert, NULL, NULL);
        
        if(!x509Cert)
        {
                //cout<<"certificate was not loaded by OpenSSL error method
has to be captured later \n\n one more thing it only supports PEM
format"<<szPath<<endl;
                cout<<"not PEM format"<<szPath<<endl;
                
                //////////might be the certificate sent is in DER fortmat so
try converting it to PEM
                //d2i_X509();
                if(!x509Cert)
                {
                        d2i_X509_fp(fPointer,NULL);
                        if(!x509Cert)
                        {
                                cout<<"The input is not a valid certificate
file"<<endl; 
                                fclose(fPointer);
                                return 0;       
                        }

                }
                                
        }

any comments on what I am doing wrong ?

regards
Muhammad Aftab Alam

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to