Swift
Swift
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 Swift Downloads
func chilkatTest() {
var success: Bool = false
let cert = CkoCert()!
success = cert.load(fromFile: "C:/certs_and_keys/Certificate.cer")
if success == false {
print("\(cert.lastErrorText!)")
return
}
let sbPem = CkoStringBuilder()!
success = sbPem.loadFile(path: "C:/certs_and_keys/PrivateKey.pem", charset: "utf-8")
if success == false {
print("Failed to load private key PEM")
return
}
success = cert.setPrivateKeyPem(privKeyPem: sbPem.getAsString())
if success == false {
print("\(cert.lastErrorText!)")
return
}
print("The certificate and associated private key are now loaded and ready for signing.")
}