-
-
Notifications
You must be signed in to change notification settings - Fork 753
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
Add support for X509_NAME_print_ex(3)
#1688
base: master
Are you sure you want to change the base?
Conversation
2f1dead
to
72f26d7
Compare
X509_name_print_ex(3)
X509_NAME_print_ex(3)
a5c0b7c
to
3dc2f1e
Compare
I'd love to get this merged, but it currently fails under the unstable BoringSSL support. This could be handled for |
You can define a cfg-dependant type for the flags, like we do in a few other places: rust-openssl/openssl/src/lib.rs Lines 187 to 190 in 0a34876
|
31082ee
to
3dc2f1e
Compare
I'd love to get the Mitigation possibilities
I tried an approach to override the An alternate solution would be to drop the use of I don't understand why there is a |
What about the thing I suggested? |
I don’t think the I submitted a patch to BoringSSL… https://boringssl-review.googlesource.com/c/boringssl/+/62146 |
Ultimately the constants are due to a bindgen bug and should be fixed there. Alas there doesn't seem to be any movement in fixing that, so we'll have to workaround it. I've got a CL in flight to fix it in a way that'll work a bit better for us. (Reproducible builds are important to us, so the build.rs mess is a bit of a problem.) That said, I would recommend rejecting this PR. This project has gotten into trouble before with using the various string-based OpenSSL APIs, and this is introducing yet more of them. Most of the flags this PR proposes to export are pretty incoherent. One even changes the return value convention of a function. If you must encode a name as a string, I'd suggest sticking to the RFC encoding, as that's the only well-defined one. Even then, that encoding is not injective. Different names will give the same string encoding. It is also not even stable across OpenSSL versions! The encoding can change as they add support for new OIDs types because they cross-reference it against the whole OID table. (Probably not a good idea.) So at minimum, the API should come with a suitable warning about when it is and isn't safe to use. |
Adds two methods: * `X509NameRef.format_bytes()` * `X509NameRef.format()` `format_bytes()` is a proxy for `X509_name_print_ex(3)`, just renamed to Rust vernacular. For a more ergonomic API in the most common use case, `format()` modifies the flags passed by the caller to ensure that OpenSSL returns UTF-8 output, then converts the BIO bytes returned to a Rust `String`. Tests included ensure that: * The most commonly-used flags, as taken from the OpenSSL man page, return expected output * The special case of `XN_FLAG_COMPAT` works as expected * Printing the name of a certificate with Unicode characters, emoji in this case, functions with both `format()` and `format_bytes()`
Not supported by LibreSSL. Not supported < `ossl110`
bitflags no longer derives traits by default, so `Clone, Copy, PartialEq, Eq` need to be derived outside the macro, per <https://docs.rs/bitflags/2.5.0/bitflags/#custom-derives>. Signed-off-by: Ross Williams <ross@ross-williams.net>
Fixes #1637, by adding two methods:
X509NameRef.format_bytes()
X509NameRef.format()
format_bytes()
is a proxy forX509_NAME_print_ex(3)
, just renamed to Rust vernacular. For a more ergonomic API in the most common use case,format()
modifies the flags passed by the caller to ensure that OpenSSL returns UTF-8 output, then converts the BIO bytes returned to a RustString
.Tests included ensure that:
XN_FLAG_COMPAT
works as expectedformat()
andformat_bytes()