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
(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_CkCert.h> #include <C_CkPrivateKey.h> void ChilkatSample(void) { HCkCert cert; BOOL success; HCkPrivateKey privKey; // The LoadFromFile method will automatically detect the file format.. cert = CkCert_Create(); success = CkCert_LoadFromFile(cert,"qa_data/zatca/cert.pem"); if (success != TRUE) { printf("%s\n",CkCert_lastErrorText(cert)); CkCert_Dispose(cert); return; } printf("%s\n",CkCert_subjectCN(cert)); // Load the private key. privKey = CkPrivateKey_Create(); success = CkPrivateKey_LoadPemFile(privKey,"qa_data/zatca/ec-secp256k1-priv-key.pem"); if (success != TRUE) { printf("%s\n",CkPrivateKey_lastErrorText(privKey)); CkCert_Dispose(cert); CkPrivateKey_Dispose(privKey); return; } printf("Key Type: %s\n",CkPrivateKey_keyType(privKey)); // Associate the private key with the certificate. success = CkCert_SetPrivateKey(cert,privKey); if (success != TRUE) { printf("%s\n",CkCert_lastErrorText(cert)); CkCert_Dispose(cert); CkPrivateKey_Dispose(privKey); return; } printf("Success.\n"); CkCert_Dispose(cert); CkPrivateKey_Dispose(privKey); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.