Skip to content

Commit

Permalink
Expose X509NameRef::print_ex
Browse files Browse the repository at this point in the history
  • Loading branch information
rushilmehra committed Aug 15, 2024
1 parent 31dab8c commit 786ee18
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion boring/src/x509/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::asn1::{
Asn1BitStringRef, Asn1IntegerRef, Asn1Object, Asn1ObjectRef, Asn1StringRef, Asn1TimeRef,
Asn1Type,
};
use crate::bio::MemBioSlice;
use crate::bio::{MemBio, MemBioSlice};
use crate::conf::ConfRef;
use crate::error::ErrorStack;
use crate::ex_data::Index;
Expand Down Expand Up @@ -1044,6 +1044,20 @@ impl X509NameRef {
}
}

/// Returns an owned String representing the X509 name configurable via incoming flags.
///
/// This function will return `None` if the underlying string contains invalid utf-8.
#[corresponds(X509_NAME_print_ex)]
pub fn print_ex(&self, flags: i32) -> Option<String> {
unsafe {
let bio = MemBio::new().ok()?;
ffi::X509_NAME_print_ex(bio.as_ptr(), self.as_ptr(), 0, flags as _);
let buf = bio.get_buf().to_vec();
let res = String::from_utf8(buf);
res.ok()
}
}

to_der! {
/// Serializes the certificate into a DER-encoded X509 name structure.
///
Expand Down

0 comments on commit 786ee18

Please sign in to comment.