@@ -396,7 +396,7 @@ def test_constants(self):
396396 ssl .OP_NO_COMPRESSION
397397 self .assertEqual (ssl .HAS_SNI , True )
398398 self .assertEqual (ssl .HAS_ECDH , True )
399- self .assertEqual (ssl .HAS_TLSv1_2 , True )
399+ self .assertIsInstance (ssl .HAS_TLSv1_2 , bool )
400400 self .assertEqual (ssl .HAS_TLSv1_3 , True )
401401 ssl .OP_NO_SSLv2
402402 ssl .OP_NO_SSLv3
@@ -587,11 +587,11 @@ def test_openssl_version(self):
587587 # Some sanity checks follow
588588 # >= 1.1.1
589589 self .assertGreaterEqual (n , 0x10101000 )
590- # < 4 .0
591- self .assertLess (n , 0x40000000 )
590+ # < 5 .0
591+ self .assertLess (n , 0x50000000 )
592592 major , minor , fix , patch , status = t
593593 self .assertGreaterEqual (major , 1 )
594- self .assertLess (major , 4 )
594+ self .assertLess (major , 5 )
595595 self .assertGreaterEqual (minor , 0 )
596596 self .assertLess (minor , 256 )
597597 self .assertGreaterEqual (fix , 0 )
@@ -657,12 +657,14 @@ def test_openssl111_deprecations(self):
657657 ssl .OP_NO_TLSv1_2 ,
658658 ssl .OP_NO_TLSv1_3
659659 ]
660- protocols = [
661- ssl .PROTOCOL_TLSv1 ,
662- ssl .PROTOCOL_TLSv1_1 ,
663- ssl .PROTOCOL_TLSv1_2 ,
664- ssl .PROTOCOL_TLS
665- ]
660+ protocols = []
661+ if hasattr (ssl , 'PROTOCOL_TLSv1' ):
662+ protocols .append (ssl .PROTOCOL_TLSv1 )
663+ if hasattr (ssl , 'PROTOCOL_TLSv1_1' ):
664+ protocols .append (ssl .PROTOCOL_TLSv1_1 )
665+ if hasattr (ssl , 'PROTOCOL_TLSv1_2' ):
666+ protocols .append (ssl .PROTOCOL_TLSv1_2 )
667+ protocols .append (ssl .PROTOCOL_TLS )
666668 versions = [
667669 ssl .TLSVersion .SSLv3 ,
668670 ssl .TLSVersion .TLSv1 ,
@@ -1156,6 +1158,7 @@ def test_min_max_version(self):
11561158 ssl .TLSVersion .TLSv1 ,
11571159 ssl .TLSVersion .TLSv1_1 ,
11581160 ssl .TLSVersion .TLSv1_2 ,
1161+ ssl .TLSVersion .TLSv1_3 ,
11591162 ssl .TLSVersion .SSLv3 ,
11601163 }
11611164 )
@@ -1169,7 +1172,7 @@ def test_min_max_version(self):
11691172 with self .assertRaises (ValueError ):
11701173 ctx .minimum_version = 42
11711174
1172- if has_tls_protocol (ssl . PROTOCOL_TLSv1_1 ):
1175+ if has_tls_protocol (' PROTOCOL_TLSv1_1' ):
11731176 ctx = ssl .SSLContext (ssl .PROTOCOL_TLSv1_1 )
11741177
11751178 self .assertIn (
@@ -1664,23 +1667,24 @@ def test__create_stdlib_context(self):
16641667 self .assertFalse (ctx .check_hostname )
16651668 self ._assert_context_options (ctx )
16661669
1667- if has_tls_protocol (ssl . PROTOCOL_TLSv1 ):
1670+ if has_tls_protocol (' PROTOCOL_TLSv1' ):
16681671 with warnings_helper .check_warnings ():
16691672 ctx = ssl ._create_stdlib_context (ssl .PROTOCOL_TLSv1 )
16701673 self .assertEqual (ctx .protocol , ssl .PROTOCOL_TLSv1 )
16711674 self .assertEqual (ctx .verify_mode , ssl .CERT_NONE )
16721675 self ._assert_context_options (ctx )
16731676
1674- with warnings_helper .check_warnings ():
1675- ctx = ssl ._create_stdlib_context (
1676- ssl .PROTOCOL_TLSv1_2 ,
1677- cert_reqs = ssl .CERT_REQUIRED ,
1678- check_hostname = True
1679- )
1680- self .assertEqual (ctx .protocol , ssl .PROTOCOL_TLSv1_2 )
1681- self .assertEqual (ctx .verify_mode , ssl .CERT_REQUIRED )
1682- self .assertTrue (ctx .check_hostname )
1683- self ._assert_context_options (ctx )
1677+ if has_tls_protocol ('PROTOCOL_TLSv1_2' ):
1678+ with warnings_helper .check_warnings ():
1679+ ctx = ssl ._create_stdlib_context (
1680+ ssl .PROTOCOL_TLSv1_2 ,
1681+ cert_reqs = ssl .CERT_REQUIRED ,
1682+ check_hostname = True
1683+ )
1684+ self .assertEqual (ctx .protocol , ssl .PROTOCOL_TLSv1_2 )
1685+ self .assertEqual (ctx .verify_mode , ssl .CERT_REQUIRED )
1686+ self .assertTrue (ctx .check_hostname )
1687+ self ._assert_context_options (ctx )
16841688
16851689 ctx = ssl ._create_stdlib_context (purpose = ssl .Purpose .CLIENT_AUTH )
16861690 self .assertEqual (ctx .protocol , ssl .PROTOCOL_TLS_SERVER )
@@ -3576,10 +3580,10 @@ def test_protocol_tlsv1_2(self):
35763580 client_options = ssl .OP_NO_TLSv1_2 )
35773581
35783582 try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLSv1_2 , 'TLSv1.2' )
3579- if has_tls_protocol (ssl . PROTOCOL_TLSv1 ):
3583+ if has_tls_protocol (' PROTOCOL_TLSv1' ):
35803584 try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_TLSv1 , False )
35813585 try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_TLSv1_2 , False )
3582- if has_tls_protocol (ssl . PROTOCOL_TLSv1_1 ):
3586+ if has_tls_protocol (' PROTOCOL_TLSv1_1' ):
35833587 try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_TLSv1_1 , False )
35843588 try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_TLSv1_2 , False )
35853589
0 commit comments