(C#) ZATCA Load Certificate and Private Key from PEM Files
Demonstrates how to load a certificate and private key from a pair of PEM files.
// The LoadFromFile method will automatically detect the file format..
Chilkat.Cert cert = new Chilkat.Cert();
bool success = cert.LoadFromFile("qa_data/zatca/cert.pem");
if (success != true) {
Debug.WriteLine(cert.LastErrorText);
return;
}
Debug.WriteLine(cert.SubjectCN);
// Load the private key.
Chilkat.PrivateKey privKey = new Chilkat.PrivateKey();
success = privKey.LoadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem");
if (success != true) {
Debug.WriteLine(privKey.LastErrorText);
return;
}
Debug.WriteLine("Key Type: " + privKey.KeyType);
// Associate the private key with the certificate.
success = cert.SetPrivateKey(privKey);
if (success != true) {
Debug.WriteLine(cert.LastErrorText);
return;
}
Debug.WriteLine("Success.");
|