diff --git a/openssl-sys/src/ssl.rs b/openssl-sys/src/ssl.rs index 12243dc4fcb56b9ac3c4d1dbd4d59d524ba9ff88..d3f09738c6389d91c664ef7a8b74b1627512dc32 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 4f349a4e4bc3167d1f90c8ac61d198dac03d39b6..ec960fa107745fd2c919082142249bacd00600f1 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.