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

Merge pull request #2018 from dhouck/x509-email

Add X509VerifyParam::set_email
parents 117b4597 c317ffe6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -118,6 +118,12 @@ extern "C" {
    #[cfg(any(ossl102, libressl261))]
    pub fn X509_VERIFY_PARAM_set_hostflags(param: *mut X509_VERIFY_PARAM, flags: c_uint);
    #[cfg(any(ossl102, libressl261))]
    pub fn X509_VERIFY_PARAM_set1_email(
        param: *mut X509_VERIFY_PARAM,
        email: *const c_char,
        emaillen: size_t,
    ) -> c_int;
    #[cfg(any(ossl102, libressl261))]
    pub fn X509_VERIFY_PARAM_set1_ip(
        param: *mut X509_VERIFY_PARAM,
        ip: *const c_uchar,
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@

## [Unreleased]

### Added
 * Added `X509VerifyParam::set_email`

## [v0.10.56] - 2023-08-06

## Added
+15 −0
Original line number Diff line number Diff line
@@ -131,6 +131,21 @@ impl X509VerifyParamRef {
        }
    }

    /// Set the expected email address.
    #[corresponds(X509_VERIFY_PARAM_set1_email)]
    pub fn set_email(&mut self, email: &str) -> Result<(), ErrorStack> {
        unsafe {
            // len == 0 means "run strlen" :(
            let raw_email = if email.is_empty() { "\0" } else { email };
            cvt(ffi::X509_VERIFY_PARAM_set1_email(
                self.as_ptr(),
                raw_email.as_ptr() as *const _,
                email.len(),
            ))
            .map(|_| ())
        }
    }

    /// Set the expected IPv4 or IPv6 address.
    #[corresponds(X509_VERIFY_PARAM_set1_ip)]
    pub fn set_ip(&mut self, ip: IpAddr) -> Result<(), ErrorStack> {