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

Method set_context

crates/stdlib/src/openssl.rs:2511–2527  ·  view source on GitHub ↗
(&self, value: PyRef<PySslContext>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2509 }
2510 #[pygetset(setter)]
2511 fn set_context(&self, value: PyRef<PySslContext>, vm: &VirtualMachine) -> PyResult<()> {
2512 // Get SSL pointer - use thread-local during handshake to avoid deadlock
2513 // (connection lock is already held during handshake)
2514 let ssl_ptr = get_ssl_ptr_for_context_change(&self.connection);
2515
2516 // Set the new SSL_CTX on the SSL object
2517 unsafe {
2518 let result = SSL_set_SSL_CTX(ssl_ptr, value.ctx().as_ptr());
2519 if result.is_null() {
2520 return Err(vm.new_runtime_error("Failed to set SSL context"));
2521 }
2522 }
2523
2524 // Update self.ctx to the new context
2525 *self.ctx.write() = value;
2526 Ok(())
2527 }
2528 #[pygetset]
2529 fn server_hostname(&self) -> Option<PyStrRef> {
2530 self.server_hostname.clone()

Callers

nothing calls this directly

Calls 5

ErrClass · 0.50
as_ptrMethod · 0.45
ctxMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected