Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix _wrap_socket
  • Loading branch information
youknowone committed Oct 26, 2025
commit 68f8655b125d814d204bffe471b137f697458211
14 changes: 14 additions & 0 deletions stdlib/src/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,20 @@ mod _ssl {
args: WrapSocketArgs,
vm: &VirtualMachine,
) -> PyResult<PySslSocket> {
// validate socket type and context protocol
if !args.server_side && zelf.protocol == SslVersion::TlsServer {
return Err(vm.new_exception_msg(
ssl_error(vm),
"Cannot create a client socket with a PROTOCOL_TLS_SERVER context".to_owned(),
));
}
if args.server_side && zelf.protocol == SslVersion::TlsClient {
return Err(vm.new_exception_msg(
ssl_error(vm),
"Cannot create a server socket with a PROTOCOL_TLS_CLIENT context".to_owned(),
));
}

let mut ssl = ssl::Ssl::new(&zelf.ctx()).map_err(|e| convert_openssl_error(vm, e))?;

let socket_type = if args.server_side {
Expand Down