(Unicode C) Get Certificate Policy
Demonstrates how to get a certificate's policy OIDs (if any)
#include <C_CkCertW.h>
#include <C_CkXmlW.h>
void ChilkatSample(void)
{
HCkCertW cert;
BOOL success;
const wchar_t *oid;
const wchar_t *strXml;
HCkXmlW xml;
cert = CkCertW_Create();
success = CkCertW_LoadFromFile(cert,L"qa_data/certs/sample.cer");
if (success == FALSE) {
wprintf(L"%s\n",CkCertW_lastErrorText(cert));
CkCertW_Dispose(cert);
return;
}
// The certificatePolicies OID is 2.5.29.32
oid = L"2.5.29.32";
strXml = CkCertW_getExtensionAsXml(cert,oid);
if (CkCertW_getLastMethodSuccess(cert) == TRUE) {
wprintf(L"%s\n",strXml);
// Sample result:
// <sequence><sequence><oid>2.16.840.1.101.2.1.11.39</oid></sequence></sequence>
xml = CkXmlW_Create();
CkXmlW_LoadXml(xml,strXml);
wprintf(L"Policy OID = %s\n",CkXmlW_getChildContent(xml,L"sequence|oid"));
}
CkCertW_Dispose(cert);
CkXmlW_Dispose(xml);
}
|