File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -884,6 +884,20 @@ mod _ssl {
884884 args : WrapSocketArgs ,
885885 vm : & VirtualMachine ,
886886 ) -> PyResult < PySslSocket > {
887+ // validate socket type and context protocol
888+ if !args. server_side && zelf. protocol == SslVersion :: TlsServer {
889+ return Err ( vm. new_exception_msg (
890+ ssl_error ( vm) ,
891+ "Cannot create a client socket with a PROTOCOL_TLS_SERVER context" . to_owned ( ) ,
892+ ) ) ;
893+ }
894+ if args. server_side && zelf. protocol == SslVersion :: TlsClient {
895+ return Err ( vm. new_exception_msg (
896+ ssl_error ( vm) ,
897+ "Cannot create a server socket with a PROTOCOL_TLS_CLIENT context" . to_owned ( ) ,
898+ ) ) ;
899+ }
900+
887901 let mut ssl = ssl:: Ssl :: new ( & zelf. ctx ( ) ) . map_err ( |e| convert_openssl_error ( vm, e) ) ?;
888902
889903 let socket_type = if args. server_side {
You can’t perform that action at this time.
0 commit comments