From 6df9f1374a97bcd5138ea2d9a84e169d9b0b74aa Mon Sep 17 00:00:00 2001 From: iamwwc Date: Fri, 2 Dec 2022 11:04:10 +0800 Subject: [PATCH] sync to rust-openssl --- openssl-sys/src/ssl.rs | 6 ++++++ openssl/src/ssl/mod.rs | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/openssl-sys/src/ssl.rs b/openssl-sys/src/ssl.rs index 12243dc4f..d3f09738c 100644 --- a/openssl-sys/src/ssl.rs +++ b/openssl-sys/src/ssl.rs @@ -339,6 +339,8 @@ pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP: c_int = 71; #[cfg(any(libressl, all(ossl101, not(ossl110))))] pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77; pub const SSL_CTRL_GET_EXTRA_CHAIN_CERTS: c_int = 82; +#[cfg(ossl102)] +pub const SSL_CTRL_CHAIN_CERT: c_int = 89; #[cfg(any(ossl111, libressl252))] pub const SSL_CTRL_SET_GROUPS_LIST: c_int = 92; #[cfg(any(libressl, all(ossl102, not(ossl110))))] @@ -406,6 +408,10 @@ cfg_if! { } } } +#[cfg(ossl102)] +pub unsafe fn SSL_add_chain_certificate_pem(ssl: *mut ::SSL, ptr: *mut c_void) -> c_long { + SSL_ctrl(ssl, SSL_CTRL_CHAIN_CERT, 1, ptr) +} #[cfg(ossl102)] pub unsafe fn SSL_CTX_set1_sigalgs_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_long { diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 4f349a4e4..ec960fa10 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -3104,6 +3104,19 @@ impl SslRef { } } } + #[corresponds(SSL_add1_chain_cert)] + #[cfg(ossl102)] + pub fn add_chain_certificate_pem(&mut self, chain: &[u8]) -> Result<(), ErrorStack> { + let cert = X509::from_pem(chain)?; + let ret = unsafe { + ffi::SSL_add_chain_certificate_pem(self.as_ptr(), cert.as_ptr() as *mut _ as *mut _) + }; + if ret == 1 { + Ok(()) + }else { + Err(ErrorStack::get()) + } + } } /// An SSL stream midway through the handshake process. -- GitLab