Sample code for 30+ languages & platforms
Lua

Example: Crypt2.GetSignedAttributes method

Demonstrates how to call the GetSignedAttributes method.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local crypt = chilkat.Crypt2.new()

local bdPkcs7 = chilkat.BinData.new()
local success = bdPkcs7:load_file("qa_data/cades/CAdES-T/Signature-C-T-1.p7m")
if not success then
    print(bdPkcs7.last_error_text)
    return
end

local json = chilkat.JsonObject.new()
json.emit_compact = false

local sbJson = chilkat.StringBuilder.new()
local i = 0
local tryNext = true
while tryNext do
    if crypt:get_signed_attributes(i, bdPkcs7, sbJson) then
        json:load_sb(sbJson)
        print(i .. ": ")
        print(json:emit())
    else
        tryNext = false
    end

    i = i + 1
end

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