Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) How to Parse a X.509 Certificate and Extract its Public KeyDemonstrates how to load an X.509 certificate and extract the public key. Chilkat supports many certificate encodings:
#include <CkCert.h> #include <CkPublicKey.h> void ChilkatSample(void) { CkString strOut; CkCert cert; // Load a DER (binary) encoded certificate. // To load from a .pem or .p7b, or any other file format that contains // just one certificate, call LoadFromFile in exactly the same way. // The LoadFromFile method automatically detects the format and loads the certificate. bool success = cert.LoadFromFile("qa_data/certs/testCert.cer"); if (success == false) { strOut.append(cert.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } // Get the public key: CkPublicKey *pubKey = cert.ExportPublicKey(); if (cert.get_LastMethodSuccess() != true) { strOut.append(cert.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } // Examine the key type. // A PublicKey object can contain an RSA, ECC, or DSA public key. // The KeyType property will contain "rsa", "ecc", or "dsa". strOut.append("key type = "); strOut.append(pubKey->keyType()); strOut.append("\r\n"); delete pubKey; SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.