Unverified Commit 6d941f20 authored by Steven Fackler's avatar Steven Fackler Committed by GitHub
Browse files

Merge pull request #1795 from AndrewScull/X509NameDup

Add X509Name::to_owned()
parents 09f672f9 33e91420
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1064,6 +1064,13 @@ impl X509NameRef {
        Ok(cmp.cmp(&0))
    }

    /// Copies the name to a new `X509Name`.
    #[corresponds(X509_NAME_dup)]
    #[cfg(any(boringssl, ossl110, libressl270))]
    pub fn to_owned(&self) -> Result<X509Name, ErrorStack> {
        unsafe { cvt_p(ffi::X509_NAME_dup(self.as_ptr())).map(|n| X509Name::from_ptr(n)) }
    }

    to_der! {
        /// Serializes the certificate into a DER-encoded X509 name structure.
        ///
+10 −0
Original line number Diff line number Diff line
@@ -615,6 +615,16 @@ fn test_name_cmp() {
    assert_eq!(Ordering::Greater, subject.try_cmp(issuer).unwrap());
}

#[test]
#[cfg(any(boringssl, ossl110, libressl270))]
fn test_name_to_owned() {
    let cert = include_bytes!("../../test/cert.pem");
    let cert = X509::from_pem(cert).unwrap();
    let name = cert.subject_name();
    let copied_name = name.to_owned().unwrap();
    assert_eq!(Ordering::Equal, name.try_cmp(&copied_name).unwrap());
}

#[test]
#[cfg(any(ossl102, libressl261))]
fn test_verify_param_set_time_fails_verification() {