Sample code for 30+ languages & platforms
Swift

Example: Crypt2.SetSigningCert method

Demonstrates how to call the SetSigningCert method.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // Signing certificates can be obtained from many different sources..

    // Load from a PFX
    let cryptA = CkoCrypt2()!
    let certA = CkoCert()!
    success = certA.loadPfxFile(path: "c:/someDir/pfx_files/a.pfx", password: "pfx_file_password")
    success = cryptA.setSigningCert(cert: certA)
    // ...

    // Load from a smart card or USB token.
    let cryptB = CkoCrypt2()!
    let certB = CkoCert()!
    certB.smartCardPin = "123456"
    success = certB.load(fromSmartcard: "")
    success = cryptB.setSigningCert(cert: certB)
    // ...

    // Load from a the Windows certificate store or macOS keychain
    let cryptC = CkoCrypt2()!
    let certC = CkoCert()!
    success = certC.load(byCommonName: "Xyz 123")
    success = cryptC.setSigningCert(cert: certC)
    // ...

}