C#
C#
Load Certificate from .cer and Private Key from .pem
See more Certificates Examples
Load a certificate from a .cer and its associated private key from a .pem.Chilkat C# Downloads
bool success = false;
Chilkat.Cert cert = new Chilkat.Cert();
success = cert.LoadFromFile("C:/certs_and_keys/Certificate.cer");
if (success == false) {
Debug.WriteLine(cert.LastErrorText);
return;
}
Chilkat.StringBuilder sbPem = new Chilkat.StringBuilder();
success = sbPem.LoadFile("C:/certs_and_keys/PrivateKey.pem","utf-8");
if (success == false) {
Debug.WriteLine("Failed to load private key PEM");
return;
}
success = cert.SetPrivateKeyPem(sbPem.GetAsString());
if (success == false) {
Debug.WriteLine(cert.LastErrorText);
return;
}
Debug.WriteLine("The certificate and associated private key are now loaded and ready for signing.");