Rust
Rust
Extract XML from FatturaPA .p7m
See more Digital Signatures Examples
Demonstrates how to verify the signature and extract the XML from a FatturaPA .p7m file.Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let bd = chilkat::BinData::new();
if bd.load_file("qa_data/p7m/IT01879020517_abc.xml.p7m").is_err() {
println!("Failed to load the .p7m file");
return;
}
let crypt = chilkat::Crypt2::new();
// Verify and extrct the payload contained within the .p7m.
// In this case, the payload is the FatturaPA XML.
// If successful, the resulting bd will contain only the XML.
if crypt.opaque_verify_bd(&bd).is_err() {
println!("{}", crypt.last_error_text());
println!("Failed to extract and verify.");
return;
}
// Save the XML to a file.
let _ = bd.write_file("qa_output/zIT01879020517_abc.xml");
// Alternatively, load into an XML object and emit.
let xml = chilkat::Xml::new();
let _ = xml.load_xml(&bd.get_string("utf-8").unwrap_or_default());
println!("{}", xml.get_xml().unwrap_or_default());