-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validation: add Rust-side trust store APIs #9744
Conversation
Signed-off-by: William Woodruff <[email protected]>
Documenting here since the context is probably lost elsewhere: the value of a separate
|
#[macro_export] | ||
macro_rules! cert { | ||
($pem:literal) => {{ | ||
let parsed = Box::leak(Box::new(pem::parse($pem).unwrap())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have questions. Namely: Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this was a convenience macro while I was writing path validation tests. It's pretty ugly though and there's no repetition here, so I can just drop it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind a convenience macro, but there's no need to be leaking things :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll see if I can work around it, but I think the leak is necessary to get the lifetimes to work -- either a macro or a full function here will have local ownership of the Pem
that's being borrowed from, so there's no way to get a lifetime shorter than 'static
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I've rewritten this as a fixture that returns a pem::Pem
and a cert(...)
helper -- that avoids the need to a leak, at the cost of a more explicit lifetime relationship between the two + binding for the pem::Pem
at each callsite 🙂
Signed-off-by: William Woodruff <[email protected]>
Breakout from #8873.