Sample code for 30+ languages & platforms
Swift

Verify the Timestamp Server Token (if any) while Validating a CMS Signature

Demonstrates how to also validate the timestamp server token (if any) while validating a CMS signature.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let crypt = CkoCrypt2()!

    // Tell Chilkat to also validate the timestamp token if a timestamp exists in the CMS message's unauthenticated attributes.
    let cmsOptions = CkoJsonObject()!
    cmsOptions.updateBool(jsonPath: "ValidateTimestampTokens", value: true)
    crypt.cmsOptions = cmsOptions.emit()

    var outputFile: String? = "qa_output/original.xml"
    var inFile: String? = "qa_data/p7m/fattura_signature.xml.p7m"

    // Verify the signature and extract the contained file, which in this case is XML.
    success = crypt.verifyP7M(p7mPath: inFile, destPath: outputFile)
    if success == false {
        print("\(crypt.lastErrorText!)")
        return
    }

    print("Signature validated.")

}