PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkCrypt2.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
success.i = 0
crypt.i = CkCrypt2::ckCreate()
If crypt.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Tell Chilkat to also validate the timestamp token if a timestamp exists in the CMS message's unauthenticated attributes.
cmsOptions.i = CkJsonObject::ckCreate()
If cmsOptions.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateBool(cmsOptions,"ValidateTimestampTokens",1)
CkCrypt2::setCkCmsOptions(crypt, CkJsonObject::ckEmit(cmsOptions))
outputFile.s = "qa_output/original.xml"
inFile.s = "qa_data/p7m/fattura_signature.xml.p7m"
; Verify the signature and extract the contained file, which in this case is XML.
success = CkCrypt2::ckVerifyP7M(crypt,inFile,outputFile)
If success = 0
Debug CkCrypt2::ckLastErrorText(crypt)
CkCrypt2::ckDispose(crypt)
CkJsonObject::ckDispose(cmsOptions)
ProcedureReturn
EndIf
Debug "Signature validated."
CkCrypt2::ckDispose(crypt)
CkJsonObject::ckDispose(cmsOptions)
ProcedureReturn
EndProcedure