Sample code for 30+ languages & platforms
Rust

Example: Crypt2.GetSignedAttributes method

Demonstrates how to call the GetSignedAttributes method.

Chilkat Rust Downloads

Rust

let crypt = chilkat::Crypt2::new();

let bd_pkcs7 = chilkat::BinData::new();
if bd_pkcs7.load_file("qa_data/cades/CAdES-T/Signature-C-T-1.p7m").is_err() {
    println!("{}", bd_pkcs7.last_error_text());
    return;
}

let json = chilkat::JsonObject::new();
json.set_emit_compact(false);

let sb_json = chilkat::StringBuilder::new();
let mut i = 0;
let mut try_next = true;
while try_next {
    if crypt.get_signed_attributes(i, &bd_pkcs7, &sb_json).is_ok() {
        let _ = json.load_sb(&sb_json);
        println!("{}: ", i);
        println!("{}", json.emit().unwrap_or_default());
    } else {
        try_next = false;
    }

    i = i + 1;
}

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