Rust
Rust
Verify XAdES with External File Reference
See more XML Digital Signatures Examples
Demonstrates how to validate an XML digital signature that contains a reference to an external file. (This is one way of doing it..)Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Load the XAdES file to be validated..
let sb_xml = chilkat::StringBuilder::new();
if sb_xml.load_file("qa_data/xml_dsig_valid_samples/externalFile/test.pdf.XAdES", "utf-8").is_err() {
println!("Failed to load XAdES input file.");
return;
}
let validator = chilkat::XmlDSig::new();
// Specify a set of absolute or relative directory paths to be searched for any external file references.
// Directory paths are separated by semicolon chars.
validator.set_external_ref_dirs("qa_data/externalFiles;qa_data/xml_dsig_valid_samples/externalFile;c:/someOtherDir");
if validator.load_signature_sb(&sb_xml).is_err() {
println!("{}", validator.last_error_text());
return;
}
// Validate signatures as usual..
let mut i = 0;
while i < validator.num_signatures() {
validator.set_selector(i);
let valid = validator.verify_signature(true).is_ok();
println!("Signature {} and all reference digests OK = {}", i + 1, valid);
i = i + 1;
}