Sample code for 30+ languages & platforms
Swift Requires Chilkat v11.0.0+

Transition from Crypt2.GetSignerCertChain to Crypt2.LastSignerCert

Provides instructions for replacing deprecated GetSignerCertChain method calls with LastSignerCert.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let crypt2 = CkoCrypt2()!

    //  ...
    //  ...
    var index: Int = 0

    //  ------------------------------------------------------------------------
    //  The GetSignerCertChain method is deprecated:

    var certchainObj: CkoCertChain? = crypt2.getSignerCertChain(index: index)
    if crypt2.lastMethodSuccess == false {
        print("\(crypt2.lastErrorText!)")
        return
    }

    //  ...
    //  ...

    certchainObj = nil

    //  ------------------------------------------------------------------------
    //  Do the equivalent using LastSignerCert, and then get the certificate chain from the cert.
    //  Your application creates a new, empty Cert object which is passed 
    //  in the last argument and filled upon success.

    let signerCert = CkoCert()!
    success = crypt2.lastSignerCert(index: index, cert: signerCert)
    if success == false {
        print("\(crypt2.lastErrorText!)")
        return
    }

    let certChain = CkoCertChain()!
    success = signerCert.buildChain(certChain: certChain)
    if success == false {
        print("\(signerCert.lastErrorText!)")
        return
    }


}