Unverified Commit 2c73dd94 authored by Steven Fackler's avatar Steven Fackler Committed by GitHub
Browse files

Merge pull request #1644 from tpambor/extension-alias

Add add_alias method to X509Extension
parents 433f0ecb d771f497
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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(
+12 −0
Original line number Diff line number Diff line
@@ -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`.