Sample code for 30+ languages & platforms
Swift

Transition from Cert.ExportPrivateKey to Cert.GetPrivateKey

Provides instructions for replacing deprecated ExportPrivateKey method calls with GetPrivateKey.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let cert = CkoCert()!

    // ------------------------------------------------------------------------
    // The ExportPrivateKey method is deprecated:

    var privatekeyObj: CkoPrivateKey? = cert.exportPrivateKey()
    if cert.lastMethodSuccess == false {
        print("\(cert.lastErrorText!)")
        return
    }

    // ...
    // ...

    privatekeyObj = nil

    // ------------------------------------------------------------------------
    // Do the equivalent using GetPrivateKey.
    // Your application creates a new, empty PrivateKey object which is passed 
    // in the last argument and filled upon success.

    let privatekeyOut = CkoPrivateKey()!
    success = cert.getPrivateKey(privKey: privatekeyOut)
    if success == false {
        print("\(cert.lastErrorText!)")
        return
    }


}