Skip to content

Commit 87eb5a7

Browse files
committed
verify_client_post_handshake
1 parent 3c7f4b0 commit 87eb5a7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

stdlib/src/ssl.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,29 @@ mod _ssl {
13201320
}
13211321
}
13221322

1323+
#[pymethod]
1324+
fn verify_client_post_handshake(&self, vm: &VirtualMachine) -> PyResult<()> {
1325+
#[cfg(ossl111)]
1326+
{
1327+
let stream = self.stream.read();
1328+
let result = unsafe { SSL_verify_client_post_handshake(stream.ssl().as_ptr()) };
1329+
if result == 0 {
1330+
Err(vm.new_exception_msg(
1331+
ssl_error(vm),
1332+
"Post-handshake authentication failed".to_owned(),
1333+
))
1334+
} else {
1335+
Ok(())
1336+
}
1337+
}
1338+
#[cfg(not(ossl111))]
1339+
{
1340+
Err(vm.new_not_implemented_error(
1341+
"Post-handshake auth is not supported by your OpenSSL version.".to_owned()
1342+
))
1343+
}
1344+
}
1345+
13231346
#[cfg(osslconf = "OPENSSL_NO_COMP")]
13241347
#[pymethod]
13251348
fn compression(&self) -> Option<&'static str> {
@@ -1637,6 +1660,11 @@ mod _ssl {
16371660
fn SSL_get_client_ciphers(ssl: *const sys::SSL) -> *const sys::stack_st_SSL_CIPHER;
16381661
}
16391662

1663+
#[cfg(ossl111)]
1664+
unsafe extern "C" {
1665+
fn SSL_verify_client_post_handshake(ssl: *const sys::SSL) -> libc::c_int;
1666+
}
1667+
16401668
// OpenSSL BIO helper functions
16411669
// These are typically macros in OpenSSL, implemented via BIO_ctrl
16421670
const BIO_CTRL_PENDING: libc::c_int = 10;

0 commit comments

Comments
 (0)