Sample code for 30+ languages & platforms
C#

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

Chilkat C# Downloads

C#
bool success = false;

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

string strPem = "-----BEGIN CERTIFICATE----- ...";

success = cert.LoadPem(strPem);
if (success == false) {
    Debug.WriteLine(cert.LastErrorText);
    return;
}

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

//  You can now use the public key object however it is needed,
//  and access its various properties and methods..

Debug.WriteLine(pubKey.GetXml());