Rust
Rust
Verify XML Digital Signature
See more XML Digital Signatures Examples
Verifies XML signatures in an XML file.Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let sb_xml = chilkat::StringBuilder::new();
if sb_xml.load_file("qa_data/xml_dsig_verify/csioz_sample.xml", "utf-8").is_err() {
println!("Failed to load XML file.");
return;
}
let dsig = chilkat::XmlDSig::new();
// First load the XML containing the signatures to be verified.
if dsig.load_signature_sb(&sb_xml).is_err() {
println!("{}", dsig.last_error_text());
return;
}
// It's possible that an XML document can contain multiple signatures.
// Each can be verified as follows:
let mut i = 0;
while i < dsig.num_signatures() {
// Select the Nth signature by setting the Selector property.
dsig.set_selector(i);
// The bVerifyReferenceDigests argument determines if we want
// to also verify each reference digest. If set to false,
// then only the SignedInfo part of the Signature is verified.
let b_verify_reference_digests = true;
let b_verified = dsig.verify_signature(b_verify_reference_digests).is_ok();
println!("Signature {} verified = {}", i + 1, b_verified);
i = i + 1;
}