Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oCrypt
LOCAL oCmsOptions
LOCAL cOutputFile
LOCAL cInFile

nSuccess := 0

oCrypt := CreateObject("Chilkat.Crypt2")

//  Tell Chilkat to also validate the timestamp token if a timestamp exists in the CMS message's unauthenticated attributes.
oCmsOptions := CreateObject("Chilkat.JsonObject")
oCmsOptions:UpdateBool("ValidateTimestampTokens", 1)
oCrypt:CmsOptions := oCmsOptions:Emit()

cOutputFile := "qa_output/original.xml"
cInFile := "qa_data/p7m/fattura_signature.xml.p7m"

//  Verify the signature and extract the contained file, which in this case is XML.
nSuccess := oCrypt:VerifyP7M(cInFile, cOutputFile)
IF (nSuccess == 0)
    ? oCrypt:LastErrorText
    oCrypt:destroy()
    oCmsOptions:destroy()
    RETURN
ENDIF

? "Signature validated."

oCrypt:destroy()
oCmsOptions:destroy()