C++
C++
Get Public Key from Certificate PEM
See more Certificates Examples
Loads a certificate from a PEM file and gets the cert's public key.Chilkat C++ Downloads
#include <CkCert.h>
#include <CkPublicKey.h>
void ChilkatSample(void)
{
bool success = false;
CkCert cert;
success = cert.LoadFromFile("qa_data/certs/someCert.pem");
if (success == false) {
std::cout << cert.lastErrorText() << "\r\n";
return;
}
// Get the certificate's public key:
CkPublicKey pubkey;
cert.GetPublicKey(pubkey);
std::cout << pubkey.getPem(false) << "\r\n";
// OK.. we have the public key which can be used in other Chilkat classes/methods...
}