Sample code for 30+ languages & platforms
Swift

Example: Crypt2.GetSignedAttributes method

Demonstrates how to call the GetSignedAttributes method.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let crypt = CkoCrypt2()!

    let bdPkcs7 = CkoBinData()!
    success = bdPkcs7.loadFile(path: "qa_data/cades/CAdES-T/Signature-C-T-1.p7m")
    if success == false {
        print("\(bdPkcs7.lastErrorText!)")
        return
    }

    let json = CkoJsonObject()!
    json.emitCompact = false

    let sbJson = CkoStringBuilder()!
    var i: Int = 0
    var tryNext: Bool = true
    while tryNext {
        if crypt.getSignedAttributes(signerIndex: i, pkcs7Der: bdPkcs7, sbJson: sbJson) == true {
            json.loadSb(sb: sbJson)
            print("\(i): ")
            print("\(json.emit()!)")
        }
        else {
            tryNext = false
        }

        i = i + 1
    }

    // Sample output:

    // 0: 
    // {
    //   "signedAttributes": [
    //     {
    //       "oid": "1.2.840.113549.1.9.3",
    //       "name": "Content Type"
    //     },
    //     {
    //       "oid": "1.2.840.113549.1.9.5",
    //       "name": "Signing Time"
    //     },
    //     {
    //       "oid": "1.2.840.113549.1.9.4",
    //       "name": "Message Digest"
    //     },
    //     {
    //       "oid": "1.2.840.113549.1.9.16.2.47",
    //       "name": "Signing Certificate V2"
    //     }
    //   ]
    // }

}