MCPcopy Index your code
hub / github.com/RustPython/RustPython / set_psk_client_callback

Method set_psk_client_callback

crates/stdlib/src/openssl.rs:1398–1429  ·  view source on GitHub ↗
(
            &self,
            callback: PyObjectRef,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1396
1397 #[pymethod]
1398 fn set_psk_client_callback(
1399 &self,
1400 callback: PyObjectRef,
1401 vm: &VirtualMachine,
1402 ) -> PyResult<()> {
1403 // Cannot add PSK client callback to a server context
1404 if self.protocol == SslVersion::TlsServer {
1405 return Err(vm
1406 .new_os_subtype_error(
1407 PySSLError::class(&vm.ctx).to_owned(),
1408 None,
1409 "Cannot add PSK client callback to a PROTOCOL_TLS_SERVER context"
1410 .to_owned(),
1411 )
1412 .upcast());
1413 }
1414
1415 if vm.is_none(&callback) {
1416 *self.psk_client_callback.lock() = None;
1417 unsafe {
1418 sys::SSL_CTX_set_psk_client_callback(self.builder().as_ptr(), None);
1419 }
1420 } else {
1421 if !callback.is_callable() {
1422 return Err(vm.new_type_error("callback must be callable"));
1423 }
1424 *self.psk_client_callback.lock() = Some(callback);
1425 // Note: The actual callback will be invoked via SSL app_data mechanism
1426 // when do_handshake is called
1427 }
1428 Ok(())
1429 }
1430
1431 #[pymethod]
1432 fn set_psk_server_callback(

Callers 2

test_pskMethod · 0.80
test_psk_tls1_3Method · 0.80

Calls 10

upcastMethod · 0.80
new_os_subtype_errorMethod · 0.80
is_callableMethod · 0.80
ErrClass · 0.50
SomeClass · 0.50
to_ownedMethod · 0.45
is_noneMethod · 0.45
lockMethod · 0.45
as_ptrMethod · 0.45
builderMethod · 0.45

Tested by 2

test_pskMethod · 0.64
test_psk_tls1_3Method · 0.64