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) ZATCA Load Certificate and Private Key from PEM FilesSee more ZATCA ExamplesDemonstrates how to load a certificate and private key from a pair of PEM files.
#include <C_CkCertW.h> #include <C_CkPrivateKeyW.h> void ChilkatSample(void) { HCkCertW cert; BOOL success; HCkPrivateKeyW privKey; // The LoadFromFile method will automatically detect the file format.. cert = CkCertW_Create(); success = CkCertW_LoadFromFile(cert,L"qa_data/zatca/cert.pem"); if (success != TRUE) { wprintf(L"%s\n",CkCertW_lastErrorText(cert)); CkCertW_Dispose(cert); return; } wprintf(L"%s\n",CkCertW_subjectCN(cert)); // Load the private key. privKey = CkPrivateKeyW_Create(); success = CkPrivateKeyW_LoadPemFile(privKey,L"qa_data/zatca/ec-secp256k1-priv-key.pem"); if (success != TRUE) { wprintf(L"%s\n",CkPrivateKeyW_lastErrorText(privKey)); CkCertW_Dispose(cert); CkPrivateKeyW_Dispose(privKey); return; } wprintf(L"Key Type: %s\n",CkPrivateKeyW_keyType(privKey)); // Associate the private key with the certificate. success = CkCertW_SetPrivateKey(cert,privKey); if (success != TRUE) { wprintf(L"%s\n",CkCertW_lastErrorText(cert)); CkCertW_Dispose(cert); CkPrivateKeyW_Dispose(privKey); return; } wprintf(L"Success.\n"); CkCertW_Dispose(cert); CkPrivateKeyW_Dispose(privKey); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.