Skip to content

Commit 2db5377

Browse files
authored
Merge pull request #2018 from dhouck/x509-email
Add X509VerifyParam::set_email
2 parents 117b459 + c317ffe commit 2db5377

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

openssl-sys/src/handwritten/x509_vfy.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ extern "C" {
118118
#[cfg(any(ossl102, libressl261))]
119119
pub fn X509_VERIFY_PARAM_set_hostflags(param: *mut X509_VERIFY_PARAM, flags: c_uint);
120120
#[cfg(any(ossl102, libressl261))]
121+
pub fn X509_VERIFY_PARAM_set1_email(
122+
param: *mut X509_VERIFY_PARAM,
123+
email: *const c_char,
124+
emaillen: size_t,
125+
) -> c_int;
126+
#[cfg(any(ossl102, libressl261))]
121127
pub fn X509_VERIFY_PARAM_set1_ip(
122128
param: *mut X509_VERIFY_PARAM,
123129
ip: *const c_uchar,

openssl/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
### Added
6+
* Added `X509VerifyParam::set_email`
7+
58
## [v0.10.56] - 2023-08-06
69

710
## Added

openssl/src/x509/verify.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,21 @@ impl X509VerifyParamRef {
131131
}
132132
}
133133

134+
/// Set the expected email address.
135+
#[corresponds(X509_VERIFY_PARAM_set1_email)]
136+
pub fn set_email(&mut self, email: &str) -> Result<(), ErrorStack> {
137+
unsafe {
138+
// len == 0 means "run strlen" :(
139+
let raw_email = if email.is_empty() { "\0" } else { email };
140+
cvt(ffi::X509_VERIFY_PARAM_set1_email(
141+
self.as_ptr(),
142+
raw_email.as_ptr() as *const _,
143+
email.len(),
144+
))
145+
.map(|_| ())
146+
}
147+
}
148+
134149
/// Set the expected IPv4 or IPv6 address.
135150
#[corresponds(X509_VERIFY_PARAM_set1_ip)]
136151
pub fn set_ip(&mut self, ip: IpAddr) -> Result<(), ErrorStack> {

0 commit comments

Comments
 (0)