Swift
Swift
Get Public Key from Certificate PEM
See more Certificates Examples
Loads a certificate from a PEM file and gets the cert's public key.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
let cert = CkoCert()!
success = cert.load(fromFile: "qa_data/certs/someCert.pem")
if success == false {
print("\(cert.lastErrorText!)")
return
}
// Get the certificate's public key:
let pubkey = CkoPublicKey()!
cert.getPublicKey(pubKey: pubkey)
print("\(pubkey.getPem(preferPkcs1: false)!)")
// OK.. we have the public key which can be used in other Chilkat classes/methods...
}