Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Convert CRL PEM to XMLLoads a CRL (Certificate Revocation List) from the PEM file format and converts to XML to allow for visual examination and parsing. Note: This example requires Chilkat v9.5.0.77 or greater.
#include <C_CkPemW.h> #include <C_CkAsnW.h> #include <C_CkXmlW.h> void ChilkatSample(void) { HCkPemW pem; BOOL success; int numCrls; int i; HCkAsnW asn; HCkXmlW xml; const wchar_t *crlBase64; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // This example requires Chilkat v9.5.0.77 or greater. pem = CkPemW_Create(); CkPemW_putVerboseLogging(pem,TRUE); success = CkPemW_LoadPemFile(pem,L"qa_data/crl/sampleCrl.pem",L"password_not_used"); if (success != TRUE) { wprintf(L"%s\n",CkPemW_lastErrorText(pem)); CkPemW_Dispose(pem); return; } numCrls = CkPemW_getNumCrls(pem); i = 0; asn = CkAsnW_Create(); xml = CkXmlW_Create(); while (i < numCrls) { // Get the CRL as base64 (multi-line) crlBase64 = CkPemW_getEncodedItem(pem,L"crl",L"",L"base64_mime",i); if (CkPemW_getLastMethodSuccess(pem) != TRUE) { wprintf(L"%s\n",CkPemW_lastErrorText(pem)); CkPemW_Dispose(pem); CkAsnW_Dispose(asn); CkXmlW_Dispose(xml); return; } wprintf(L"%s\n",crlBase64); success = CkAsnW_LoadEncoded(asn,crlBase64,L"base64"); if (success != TRUE) { wprintf(L"%s\n",CkAsnW_lastErrorText(asn)); CkPemW_Dispose(pem); CkAsnW_Dispose(asn); CkXmlW_Dispose(xml); return; } // Convert ASN.1 to XML and load into xml and re-emit for pretty printing.. CkXmlW_LoadXml(xml,CkAsnW_asnToXml(asn)); wprintf(L"%s\n",CkXmlW_getXml(xml)); // Use this online tool to generate parsing code from CRL XML: // Generate Parsing Code from XML wprintf(L"-------------------------------------\n"); i = i + 1; } CkPemW_Dispose(pem); CkAsnW_Dispose(asn); CkXmlW_Dispose(xml); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.