File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Open diff view settings
Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -3263,7 +3263,6 @@ def test_check_hostname_idn(self, warnings_filters=True):
32633263 server_hostname = b'k\xf6 nig.idn.pythontest.net' ,
32643264 )
32653265
3266- @unittest .expectedFailure # TODO: RUSTPYTHON
32673266 def test_wrong_cert_tls12 (self ):
32683267 """Connecting when the server rejects the client's certificate
32693268
@@ -4042,7 +4041,6 @@ def test_min_max_version_sslv3(self):
40424041 s .connect ((HOST , server .port ))
40434042 self .assertEqual (s .version (), 'SSLv3' )
40444043
4045- @unittest .expectedFailure # TODO: RUSTPYTHON
40464044 def test_default_ecdh_curve (self ):
40474045 # Issue #21015: elliptic curve-based Diffie Hellman key exchange
40484046 # should be enabled by default on SSL contexts.
Original file line number Diff line number Diff line change @@ -802,6 +802,47 @@ mod _ssl {
802802 self . check_hostname . store ( ch) ;
803803 }
804804
805+ // PY_PROTO_MINIMUM_SUPPORTED = -2, PY_PROTO_MAXIMUM_SUPPORTED = -1
806+ #[ pygetset]
807+ fn minimum_version ( & self ) -> i32 {
808+ let ctx = self . ctx ( ) ;
809+ let version = unsafe { sys:: SSL_CTX_get_min_proto_version ( ctx. as_ptr ( ) ) } ;
810+ if version == 0 {
811+ -2 // PY_PROTO_MINIMUM_SUPPORTED
812+ } else {
813+ version
814+ }
815+ }
816+ #[ pygetset( setter) ]
817+ fn set_minimum_version ( & self , value : i32 , vm : & VirtualMachine ) -> PyResult < ( ) > {
818+ let ctx = self . builder ( ) ;
819+ let result = unsafe { sys:: SSL_CTX_set_min_proto_version ( ctx. as_ptr ( ) , value) } ;
820+ if result == 0 {
821+ return Err ( vm. new_value_error ( "invalid protocol version" ) ) ;
822+ }
823+ Ok ( ( ) )
824+ }
825+
826+ #[ pygetset]
827+ fn maximum_version ( & self ) -> i32 {
828+ let ctx = self . ctx ( ) ;
829+ let version = unsafe { sys:: SSL_CTX_get_max_proto_version ( ctx. as_ptr ( ) ) } ;
830+ if version == 0 {
831+ -1 // PY_PROTO_MAXIMUM_SUPPORTED
832+ } else {
833+ version
834+ }
835+ }
836+ #[ pygetset( setter) ]
837+ fn set_maximum_version ( & self , value : i32 , vm : & VirtualMachine ) -> PyResult < ( ) > {
838+ let ctx = self . builder ( ) ;
839+ let result = unsafe { sys:: SSL_CTX_set_max_proto_version ( ctx. as_ptr ( ) , value) } ;
840+ if result == 0 {
841+ return Err ( vm. new_value_error ( "invalid protocol version" ) ) ;
842+ }
843+ Ok ( ( ) )
844+ }
845+
805846 #[ pymethod]
806847 fn set_default_verify_paths ( & self , vm : & VirtualMachine ) -> PyResult < ( ) > {
807848 cfg_if:: cfg_if! {
You can’t perform that action at this time.
0 commit comments