Skip to content

Commit 7b643da

Browse files
committed
add ssl.SSLContext.post_handshake_auth
1 parent 6d40b70 commit 7b643da

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

stdlib/src/ssl.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod _ssl {
2626
use crate::{
2727
common::{
2828
ascii,
29-
lock::{PyRwLock, PyRwLockWriteGuard},
29+
lock::{PyMutex, PyRwLock, PyRwLockWriteGuard},
3030
},
3131
socket::{self, PySocket},
3232
vm::{
@@ -423,6 +423,7 @@ mod _ssl {
423423
ctx: PyRwLock<SslContextBuilder>,
424424
check_hostname: AtomicCell<bool>,
425425
protocol: SslVersion,
426+
post_handshake_auth: PyMutex<bool>,
426427
}
427428

428429
impl fmt::Debug for PySslContext {
@@ -491,6 +492,7 @@ mod _ssl {
491492
ctx: PyRwLock::new(builder),
492493
check_hostname: AtomicCell::new(check_hostname),
493494
protocol: proto,
495+
post_handshake_auth: PyMutex::new(false),
494496
}
495497
.into_ref_with_type(vm, cls)
496498
.map(Into::into)
@@ -510,6 +512,22 @@ mod _ssl {
510512
func(builder_as_ctx(&c))
511513
}
512514

515+
#[pyproperty]
516+
fn post_handshake_auth(&self) -> bool {
517+
*self.post_handshake_auth.lock()
518+
}
519+
#[pyproperty(setter)]
520+
fn set_post_handshake_auth(
521+
&self,
522+
value: Option<PyObjectRef>,
523+
vm: &VirtualMachine,
524+
) -> PyResult<()> {
525+
let value = value
526+
.ok_or_else(|| vm.new_attribute_error("cannot delete attribute".to_owned()))?;
527+
*self.post_handshake_auth.lock() = value.is_true(vm)?;
528+
Ok(())
529+
}
530+
513531
#[pymethod]
514532
fn set_ciphers(&self, cipherlist: PyStrRef, vm: &VirtualMachine) -> PyResult<()> {
515533
let ciphers = cipherlist.as_str();

0 commit comments

Comments
 (0)