On Tue, Jan 08, 2008, sunilv wrote:
>
> Hi,
>
> Presently I am using the certificate authentication for one application.
> In that one,am reading the certificate thru C program.
> In that program am using the function called X509_get_ext_d2i.
> When I am trying to retrieve the value of the extension serialNumber , it is
> throwing the error it couldn't find the extension serialNumber in the
> certificate.
> But in the certificate the serialNumber is available.Am bit confused why it
> is throwing this kind of error?
> And my code looks like below.
>
> =====================
> nid=OBJ_sn2nid(trimmedExtensionName);
> if(nid == FALSE)
> {
> fprintf(stderr,"Unable to get the NID for
> %s\n",trimmedExtensionName);
> return FALSE;
> }
>
> altnames = (STACK *)X509_get_ext_d2i(cert, nid, crit, idx);
> ===========================
>
> In the above scenario first I am getting the nid of the extension by passing
> the extension name.
> In the second step, using the NID am getting the value of the extension.
>
> This code working fine for subjectalternativename extension.
>
> In case anybody knows about this please let me know.
>
The structure returned by X509_get_ext_d2i() depends on the extension type, so
not everything will return altnames.
In this case serialNumber isn't an extension but is in fact a DN component.
You need to use the X509_NAME functions to retrieve it.
Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [EMAIL PROTECTED]