Sample code for 30+ languages & platforms
Xbase++

Example: Crypt2.GetSignedAttributes method

Demonstrates how to call the GetSignedAttributes method.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oCrypt
LOCAL oBdPkcs7
LOCAL oJson
LOCAL oSbJson
LOCAL i
LOCAL nTryNext

nSuccess := 0

oCrypt := CreateObject("Chilkat.Crypt2")

oBdPkcs7 := CreateObject("Chilkat.BinData")
nSuccess := oBdPkcs7:LoadFile("qa_data/cades/CAdES-T/Signature-C-T-1.p7m")
IF (nSuccess == 0)
    ? oBdPkcs7:LastErrorText
    oCrypt:destroy()
    oBdPkcs7:destroy()
    RETURN
ENDIF

oJson := CreateObject("Chilkat.JsonObject")
oJson:EmitCompact := 0

oSbJson := CreateObject("Chilkat.StringBuilder")
i := 0
nTryNext := 1
DO WHILE nTryNext
    IF (oCrypt:GetSignedAttributes(i, oBdPkcs7, oSbJson) == 1)
        oJson:LoadSb(oSbJson)
        ? Str(i) + ": "
        ? oJson:Emit()
    ELSE
        nTryNext := 0
    ENDIF

    i := i + 1
ENDDO

//  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"
//      }
//    ]
//  }

oCrypt:destroy()
oBdPkcs7:destroy()
oJson:destroy()
oSbJson:destroy()