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

Merge pull request #1743 from iamwwc/sync-to-original

SSL_add_chain_certificate_pem to add chain certificate on SslRef
parents eaee3834 24363b3e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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_add1_chain_cert(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 {
+10 −0
Original line number Diff line number Diff line
@@ -3104,6 +3104,16 @@ impl SslRef {
            }
        }
    }
    #[corresponds(SSL_add1_chain_cert)]
    #[cfg(ossl102)]
    pub fn add_chain_cert(&mut self, chain: X509) -> Result<(), ErrorStack> {
        let ret = unsafe { ffi::SSL_add1_chain_cert(self.as_ptr(), chain.as_ptr() as *mut _) };
        if ret == 1 {
            Ok(())
        } else {
            Err(ErrorStack::get())
        }
    }
}

/// An SSL stream midway through the handshake process.
+9 −0
Original line number Diff line number Diff line
@@ -1413,3 +1413,12 @@ fn session_cache_size() {
    let ctx = ctx.build();
    assert_eq!(ctx.session_cache_size(), 1234);
}

#[test]
#[cfg(ossl102)]
fn add_chain_cert() {
    let ctx = SslContext::builder(SslMethod::tls()).unwrap().build();
    let cert = X509::from_pem(CERT).unwrap();
    let mut ssl = Ssl::new(&ctx).unwrap();
    assert!(ssl.add_chain_cert(cert).is_ok());
}