Sample code for 30+ languages & platforms
Swift

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let cert = CkoCert()!

    var strPem: String? = "-----BEGIN CERTIFICATE----- ..."

    success = cert.loadPem(strPem: strPem)
    if success == false {
        print("\(cert.lastErrorText!)")
        return
    }

    let pubKey = CkoPublicKey()!
    cert.getPublicKey(pubKey: pubKey)

    // You can now use the public key object however it is needed,
    // and access its various properties and methods..

    print("\(pubKey.getXml()!)")

}