(Swift) Transition from Cert.ExportPrivateKey to Cert.GetPrivateKey
Provides instructions for replacing deprecated ExportPrivateKey method calls with GetPrivateKey. Note: This example requires Chilkat v11.0.0 or greater.
func chilkatTest() {
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()!
var success: Bool = cert.get(privatekeyOut)
if success == false {
print("\(cert.lastErrorText!)")
return
}
}
|