Hello,
I'm currently working on a project using mod_ssl which has to do the following:
1. Create a SSL Environment Variable
- I created the Environment Variable "CERTPOL" the module
ssl_engine_kernel.c
2. Retrieve the certificatePolicy field
- In module ssl_engine_vars.c I call the following function :
char *SSL_X509_certificate_policies(X509 *)
- This function was included in module ssl_util_ssl.c
***3. Decode the certificatePolicy from DER to text and store it in the CERTPOL
Environment Variable
This is where my problem starts!!
I seem to be getting the ENCODED certificatePolicy field, but I can't DECODE
it to text.
I tried using d2i_POLICYINFO(&qinfo, &data, length); but my program crashes.
I am able to use the function hex_to_string(data, length) which displays
the following:
SSL_CERTPOL="2B:06:01:04:01:86:71:05:03:04"
Here is the code I am currently using:
char* SSL_X509_certificate_policy(X509 *cert)
{
X509_EXTENSION *ext;
POLICYINFO *pinfo=NULL;
STACK *sk;
ASN1_OBJECT *ao;
int idx;
char *temp;
unsigned char *data;
long length;
pinfo = (POLICYINFO *) malloc(sizeof(POLICYINFO));
idx = X509_get_ext_by_NID(cert, NID_certificate_policies, 0);
if (idx >= 0)
{
ext = X509_get_ext(cert, idx);
if (ext != NULL)
{
if ((sk = (STACK *)X509V3_EXT_d2i(ext)) != NULL)
{
pinfo = (POLICYINFO *)sk_value(sk, 0);
data = pinfo->policyid->data; //ASN1_OBJECT
*policyid
length = pinfo->policyid->length;
//strcpy(temp, data); //displays
encoded data
temp = hex_to_string(data, length); //displays hex
data
}
}
}
POLICYINFO_free(pinfo);
return temp;
}
Please help me solve this problem.
I would be very greatful
Thank you very much
Ian MacLean :-)
______________________________________________________________________
Apache Interface to OpenSSL (mod_ssl) www.modssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]