Arthur Wongtschowski wrote:
> 
> > Using the following code, I manage to add a lot of extensions to a
> > certificate.
> >
> >
> >       X509V3_EXT_METHOD *method;
> >       STACK_OF(CONF_VALUE) *nval;
> >       int ext_len;
> >       unsigned char *ext_der;
> >       void *ext_struc;
> >       int ext_nid;
> >       ASN1_OCTET_STRING *ext_oct;
> >       X509_EXTENSION *ext;
> >
> >       ext_nid = OBJ_sn2nid(name);
> >
> >       method = X509V3_EXT_get_nid(ext_nid);
> >       nval = X509V3_parse_list(value);
> >
> >       if(method->v2i)
> >               ext_struc = method->v2i(method, NULL, nval);
> >       else if(method->s2i)
> >               ext_struc = method->s2i(method, NULL, value);
> >       else if(method->r2i)
> >               ext_struc = method->r2i(method, NULL, value);
> >
> >       ext_len = method->i2d(ext_struc, NULL);
> >       ext_der = (unsigned char *)OPENSSL_malloc(ext_len);
> >       p = ext_der;
> >       method->i2d(ext_struc, &p);
> >
> >       ext_oct = M_ASN1_OCTET_STRING_new();
> >       ext_oct->data = ext_der;
> >       ext_oct->length = ext_len;
> >
> >       ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, 0, ext_oct);
> >       M_ASN1_OCTET_STRING_free(ext_oct);
> >
> >       X509_add_ext(cert, ext, -1);
> >
> > , where "cert" is of type X509.
> >
> > This code works form the folowing values of the variables "name" and
> > "value"
> >
> > name = "keyUsage", value = "nonRepudiation, digitalSignature,
> > keyEncipherment";
> >
> > name = "crlDistributionPoints", value = "URI:http://myserver/CRL.asp";
> >
> > name = "extendedKeyUsage", value = "serverAuth, emailProtection"
> >
> >   The problem is : I'm not being able to add the "authorityKeyIdentifier"
> > extension. Does any one knows what the value for the variable "value"
> > whould be in this case ? I would really apreciate some help... Thanks !
> >

Don't use that code. It looks like its been snipped from the library
internal functions: it works at a low level which accesses such things
as structure internals which aren't guaranteed to change. 

The correct high level functions are much easier to use and are
documented in doc/openssl.txt as indicated in the FAQ.

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Gemplus: http://www.gemplus.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to