(Swift) ZATCA Load Certificate and Private Key from PEM Files
Demonstrates how to load a certificate and private key from a pair of PEM files.
func chilkatTest() {
// The LoadFromFile method will automatically detect the file format..
let cert = CkoCert()!
var success: Bool = cert.load(fromFile: "qa_data/zatca/cert.pem")
if success != true {
print("\(cert.lastErrorText!)")
return
}
print("\(cert.subjectCN!)")
// Load the private key.
let privKey = CkoPrivateKey()!
success = privKey.loadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem")
if success != true {
print("\(privKey.lastErrorText!)")
return
}
print("Key Type: \(privKey.keyType!)")
// Associate the private key with the certificate.
success = cert.setPrivateKey(privKey)
if success != true {
print("\(cert.lastErrorText!)")
return
}
print("Success.")
}
|