(C) Get Certificate Policy
Demonstrates how to get a certificate's policy OIDs (if any)
#include <C_CkCert.h>
#include <C_CkXml.h>
void ChilkatSample(void)
{
HCkCert cert;
BOOL success;
const char *oid;
const char *strXml;
HCkXml xml;
cert = CkCert_Create();
success = CkCert_LoadFromFile(cert,"qa_data/certs/sample.cer");
if (success == FALSE) {
printf("%s\n",CkCert_lastErrorText(cert));
CkCert_Dispose(cert);
return;
}
// The certificatePolicies OID is 2.5.29.32
oid = "2.5.29.32";
strXml = CkCert_getExtensionAsXml(cert,oid);
if (CkCert_getLastMethodSuccess(cert) == TRUE) {
printf("%s\n",strXml);
// Sample result:
// <sequence><sequence><oid>2.16.840.1.101.2.1.11.39</oid></sequence></sequence>
xml = CkXml_Create();
CkXml_LoadXml(xml,strXml);
printf("Policy OID = %s\n",CkXml_getChildContent(xml,"sequence|oid"));
}
CkCert_Dispose(cert);
CkXml_Dispose(xml);
}
|