Skip to content

Conversation

@Qubitza
Copy link

@Qubitza Qubitza commented Aug 20, 2025

As proposed in #15 I introduced the feature to define a URI mapping for local file signatures.

You can either set the actual local file path for a URI or directly pass the content for a defined URI

    ctx.set_uri_mapping({
        let mut map = HashMap::new();
        map.insert(
            "data.json".to_string(),
            UriResource::Data(r#"{"some": "file content"}"#.as_bytes().to_vec()),
        );
        map.insert(
            "another.json".to_string(),
            UriResource::Path(PathBuf::from("some/path/to/another.json")),
        );
        map
    });

The biggest pain point was the fact that the callback functions from xmlsec1 don't provide the context.
This would have allowed to put the mapping into the user_data field.
To solve this challenge, the mapping is written into (and removed afterward) a thread-static variable when sign or validate is invoked.

As I'm not a rust expert feel free to provide improvements.

EcdsaSha384,
EcdsaSha512,
HmacMd5,
// HmacMd5,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to disable MD5 as it was not included in my openssl version.
Feel free to add it back in, if you think MD5 is still a thing.

Comment on lines +252 to +259
if bindings::xmlSecIORegisterCallbacks(
Some(io_match_callback),
Some(io_open_callback),
Some(io_read_callback),
Some(io_close_callback),
) < 0 {
panic!("Failed to register IO callbacks");
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part where the callbacks are set which allow to resolve URI by our own code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant