Skip to content

Commit

Permalink
Merge pull request #1644 from tpambor/extension-alias
Browse files Browse the repository at this point in the history
Add add_alias method to X509Extension
  • Loading branch information
sfackler authored May 30, 2022
2 parents 433f0ec + d771f49 commit 2c73dd9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions openssl-sys/src/handwritten/x509v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const_ptr_api! {
}

extern "C" {
pub fn X509V3_EXT_add_alias(nid_to: c_int, nid_from: c_int) -> c_int;
pub fn X509V3_EXT_d2i(ext: *mut X509_EXTENSION) -> *mut c_void;
pub fn X509V3_EXT_i2d(ext_nid: c_int, crit: c_int, ext: *mut c_void) -> *mut X509_EXTENSION;
pub fn X509V3_add1_i2d(
Expand Down
12 changes: 12 additions & 0 deletions openssl/src/x509/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,18 @@ impl X509Extension {
cvt_p(ffi::X509V3_EXT_nconf_nid(conf, context, name, value)).map(X509Extension)
}
}

/// Adds an alias for an extension
///
/// This corresponds to [`X509V3_EXT_add_alias`]
///
/// # Safety
///
/// This method modifies global state without locking and therefore is not thread safe
pub unsafe fn add_alias(to: Nid, from: Nid) -> Result<(), ErrorStack> {
ffi::init();
cvt(ffi::X509V3_EXT_add_alias(to.as_raw(), from.as_raw())).map(|_| ())
}
}

/// A builder used to construct an `X509Name`.
Expand Down

0 comments on commit 2c73dd9

Please sign in to comment.