Sample code for 30+ languages & platforms
.NET Core C#

Get Certificate Public Key from PEM

See more Certificates Examples

Demonstrates how to load a PEM file containing a certificate and access the public key.

Chilkat .NET Core C# Downloads

.NET Core C#
bool success = false;

Chilkat.Cert cert = new Chilkat.Cert();

success = cert.LoadFromFile("qa_data/pem/my_cert.pem");
if (success == false) {
    Debug.WriteLine(cert.LastErrorText);
    return;
}

Chilkat.PublicKey pubkey = new Chilkat.PublicKey();
cert.GetPublicKey(pubkey);

// Examine the public key as XML..
Debug.WriteLine(pubkey.GetXml());