On Thu, Jan 21, 2010, Ujwal Chinthala wrote:

> Hi,
> 
> Thanks for the all the help.
> 
> I see the same error  when I am trying to create a x509 certificate using the 
> DSA parameters g, p, q and public key y.
> These parameters are generated by the GetPublicKey API in C#. All the above 
> parameters are BYTE arrays.
> Find the DSA parameters attached.
> 
>                 ......
> //
> BN_bin2bn((const unsigned char *)uLicenseCheckG, sizeof(uLicenseCheckG), 
> dsaParams->g);
>       BN_bin2bn((const unsigned char *)uLicenseCheckP, 
> sizeof(uLicenseCheckP), dsaParams->p);
>       BN_bin2bn((const unsigned char *)uLicenseCheckQ, 
> sizeof(uLicenseCheckQ), dsaParams->q);
>       BN_bin2bn((const unsigned char *)uLicenseCheckY, 
> sizeof(uLicenseCheckY), dsaParams->pub_key);
> 
> unsigned char *buff;
>       int nLength;
>       nLength = i2d_DSA_PUBKEY(dsaParams, &buff);
> 
>       X509 *x509Cert = X509_new();
>       const unsigned char *p;
>       p = buff;
>       x509Cert = d2i_X509(NULL, &p, nLength); // Problem occurs here, 
> x509Cert is NULL and the error is the same as before <--
> 
>       STACK_OF(X509) *st=sk_X509_new_null(); // I want to use this stack of 
> x509 in CMS_verify
>       sk_X509_push(st, x509Cert);
> 

Well you've encoded (incorrectly, buff should be set to NULL) a
SubjectPublicKeyInfo structure and then attempted to decode it as a
certificate. It's not surprising it failed: the two are different structures.

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to