19
19
import platform
20
20
import functools
21
21
import sysconfig
22
+ import functools
22
23
try :
23
24
import ctypes
24
25
except ImportError :
@@ -142,6 +143,87 @@ def data_file(*name):
142
143
OP_ENABLE_MIDDLEBOX_COMPAT = getattr (ssl , "OP_ENABLE_MIDDLEBOX_COMPAT" , 0 )
143
144
144
145
146
+ def has_tls_protocol (protocol ):
147
+ """Check if a TLS protocol is available and enabled
148
+
149
+ :param protocol: enum ssl._SSLMethod member or name
150
+ :return: bool
151
+ """
152
+ if isinstance (protocol , str ):
153
+ assert protocol .startswith ('PROTOCOL_' )
154
+ protocol = getattr (ssl , protocol , None )
155
+ if protocol is None :
156
+ return False
157
+ if protocol in {
158
+ ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLS_SERVER ,
159
+ ssl .PROTOCOL_TLS_CLIENT
160
+ }:
161
+ # auto-negotiate protocols are always available
162
+ return True
163
+ name = protocol .name
164
+ return has_tls_version (name [len ('PROTOCOL_' ):])
165
+
166
+
167
+ @functools .lru_cache ()
168
+ def has_tls_version (version ):
169
+ """Check if a TLS/SSL version is enabled
170
+
171
+ :param version: TLS version name or ssl.TLSVersion member
172
+ :return: bool
173
+ """
174
+ if version == "SSLv2" :
175
+ # never supported and not even in TLSVersion enum
176
+ return False
177
+
178
+ if isinstance (version , str ):
179
+ version = ssl .TLSVersion .__members__ [version ]
180
+
181
+ # check compile time flags like ssl.HAS_TLSv1_2
182
+ if not getattr (ssl , f'HAS_{ version .name } ' ):
183
+ return False
184
+
185
+ # check runtime and dynamic crypto policy settings. A TLS version may
186
+ # be compiled in but disabled by a policy or config option.
187
+ ctx = ssl .SSLContext ()
188
+ if (
189
+ hasattr (ctx , 'minimum_version' ) and
190
+ ctx .minimum_version != ssl .TLSVersion .MINIMUM_SUPPORTED and
191
+ version < ctx .minimum_version
192
+ ):
193
+ return False
194
+ if (
195
+ hasattr (ctx , 'maximum_version' ) and
196
+ ctx .maximum_version != ssl .TLSVersion .MAXIMUM_SUPPORTED and
197
+ version > ctx .maximum_version
198
+ ):
199
+ return False
200
+
201
+ return True
202
+
203
+
204
+ def requires_tls_version (version ):
205
+ """Decorator to skip tests when a required TLS version is not available
206
+
207
+ :param version: TLS version name or ssl.TLSVersion member
208
+ :return:
209
+ """
210
+ def decorator (func ):
211
+ @functools .wraps (func )
212
+ def wrapper (* args , ** kw ):
213
+ if not has_tls_version (version ):
214
+ raise unittest .SkipTest (f"{ version } is not available." )
215
+ else :
216
+ return func (* args , ** kw )
217
+ return wrapper
218
+ return decorator
219
+
220
+
221
+ requires_minimum_version = unittest .skipUnless (
222
+ hasattr (ssl .SSLContext , 'minimum_version' ),
223
+ "required OpenSSL >= 1.1.0g"
224
+ )
225
+
226
+
145
227
def handle_error (prefix ):
146
228
exc_format = ' ' .join (traceback .format_exception (* sys .exc_info ()))
147
229
if support .verbose :
@@ -1124,19 +1206,23 @@ def test_hostname_checks_common_name(self):
1124
1206
with self .assertRaises (AttributeError ):
1125
1207
ctx .hostname_checks_common_name = True
1126
1208
1127
- @unittest . skipUnless ( hasattr ( ssl . SSLContext , 'minimum_version' ),
1128
- "required OpenSSL 1.1.0g " )
1209
+ @requires_minimum_version
1210
+ @ unittest . skipIf ( IS_LIBRESSL , "see bpo-34001 " )
1129
1211
def test_min_max_version (self ):
1130
1212
ctx = ssl .SSLContext (ssl .PROTOCOL_TLS_SERVER )
1131
1213
# OpenSSL default is MINIMUM_SUPPORTED, however some vendors like
1132
1214
# Fedora override the setting to TLS 1.0.
1215
+ minimum_range = {
1216
+ # stock OpenSSL
1217
+ ssl .TLSVersion .MINIMUM_SUPPORTED ,
1218
+ # Fedora 29 uses TLS 1.0 by default
1219
+ ssl .TLSVersion .TLSv1 ,
1220
+ # RHEL 8 uses TLS 1.2 by default
1221
+ ssl .TLSVersion .TLSv1_2
1222
+ }
1223
+
1133
1224
self .assertIn (
1134
- ctx .minimum_version ,
1135
- {ssl .TLSVersion .MINIMUM_SUPPORTED ,
1136
- # Fedora 29 uses TLS 1.0 by default
1137
- ssl .TLSVersion .TLSv1 ,
1138
- # RHEL 8 uses TLS 1.2 by default
1139
- ssl .TLSVersion .TLSv1_2 }
1225
+ ctx .minimum_version , minimum_range
1140
1226
)
1141
1227
self .assertEqual (
1142
1228
ctx .maximum_version , ssl .TLSVersion .MAXIMUM_SUPPORTED
@@ -1182,8 +1268,8 @@ def test_min_max_version(self):
1182
1268
1183
1269
ctx = ssl .SSLContext (ssl .PROTOCOL_TLSv1_1 )
1184
1270
1185
- self .assertEqual (
1186
- ctx .minimum_version , ssl . TLSVersion . MINIMUM_SUPPORTED
1271
+ self .assertIn (
1272
+ ctx .minimum_version , minimum_range
1187
1273
)
1188
1274
self .assertEqual (
1189
1275
ctx .maximum_version , ssl .TLSVersion .MAXIMUM_SUPPORTED
@@ -2723,6 +2809,8 @@ def test_echo(self):
2723
2809
for protocol in PROTOCOLS :
2724
2810
if protocol in {ssl .PROTOCOL_TLS_CLIENT , ssl .PROTOCOL_TLS_SERVER }:
2725
2811
continue
2812
+ if not has_tls_protocol (protocol ):
2813
+ continue
2726
2814
with self .subTest (protocol = ssl ._PROTOCOL_NAMES [protocol ]):
2727
2815
context = ssl .SSLContext (protocol )
2728
2816
context .load_cert_chain (CERTFILE )
@@ -3014,7 +3102,7 @@ def test_wrong_cert_tls12(self):
3014
3102
else :
3015
3103
self .fail ("Use of invalid cert should have failed!" )
3016
3104
3017
- @unittest . skipUnless ( ssl . HAS_TLSv1_3 , "Test needs TLS 1.3" )
3105
+ @requires_tls_version ( 'TLSv1_3' )
3018
3106
def test_wrong_cert_tls13 (self ):
3019
3107
client_context , server_context , hostname = testing_context ()
3020
3108
# load client cert that is not signed by trusted CA
@@ -3109,9 +3197,7 @@ def test_ssl_cert_verify_error(self):
3109
3197
self .assertIn (msg , repr (e ))
3110
3198
self .assertIn ('certificate verify failed' , repr (e ))
3111
3199
3112
- @skip_if_broken_ubuntu_ssl
3113
- @unittest .skipUnless (hasattr (ssl , 'PROTOCOL_SSLv2' ),
3114
- "OpenSSL is compiled without SSLv2 support" )
3200
+ @requires_tls_version ('SSLv2' )
3115
3201
def test_protocol_sslv2 (self ):
3116
3202
"""Connecting to an SSLv2 server with various client options"""
3117
3203
if support .verbose :
@@ -3120,7 +3206,7 @@ def test_protocol_sslv2(self):
3120
3206
try_protocol_combo (ssl .PROTOCOL_SSLv2 , ssl .PROTOCOL_SSLv2 , True , ssl .CERT_OPTIONAL )
3121
3207
try_protocol_combo (ssl .PROTOCOL_SSLv2 , ssl .PROTOCOL_SSLv2 , True , ssl .CERT_REQUIRED )
3122
3208
try_protocol_combo (ssl .PROTOCOL_SSLv2 , ssl .PROTOCOL_TLS , False )
3123
- if hasattr ( ssl , 'PROTOCOL_SSLv3 ' ):
3209
+ if has_tls_version ( 'SSLv3 ' ):
3124
3210
try_protocol_combo (ssl .PROTOCOL_SSLv2 , ssl .PROTOCOL_SSLv3 , False )
3125
3211
try_protocol_combo (ssl .PROTOCOL_SSLv2 , ssl .PROTOCOL_TLSv1 , False )
3126
3212
# SSLv23 client with specific SSL options
@@ -3138,7 +3224,7 @@ def test_PROTOCOL_TLS(self):
3138
3224
"""Connecting to an SSLv23 server with various client options"""
3139
3225
if support .verbose :
3140
3226
sys .stdout .write ("\n " )
3141
- if hasattr ( ssl , 'PROTOCOL_SSLv2 ' ):
3227
+ if has_tls_version ( 'SSLv2 ' ):
3142
3228
try :
3143
3229
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_SSLv2 , True )
3144
3230
except OSError as x :
@@ -3147,43 +3233,44 @@ def test_PROTOCOL_TLS(self):
3147
3233
sys .stdout .write (
3148
3234
" SSL2 client to SSL23 server test unexpectedly failed:\n %s\n "
3149
3235
% str (x ))
3150
- if hasattr ( ssl , 'PROTOCOL_SSLv3 ' ):
3236
+ if has_tls_version ( 'SSLv3 ' ):
3151
3237
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_SSLv3 , False )
3152
3238
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLS , True )
3153
- try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLSv1 , 'TLSv1' )
3239
+ if has_tls_version ('TLSv1' ):
3240
+ try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLSv1 , 'TLSv1' )
3154
3241
3155
- if hasattr ( ssl , 'PROTOCOL_SSLv3 ' ):
3242
+ if has_tls_version ( 'SSLv3 ' ):
3156
3243
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_SSLv3 , False , ssl .CERT_OPTIONAL )
3157
3244
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLS , True , ssl .CERT_OPTIONAL )
3158
- try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLSv1 , 'TLSv1' , ssl .CERT_OPTIONAL )
3245
+ if has_tls_version ('TLSv1' ):
3246
+ try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLSv1 , 'TLSv1' , ssl .CERT_OPTIONAL )
3159
3247
3160
- if hasattr ( ssl , 'PROTOCOL_SSLv3 ' ):
3248
+ if has_tls_version ( 'SSLv3 ' ):
3161
3249
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_SSLv3 , False , ssl .CERT_REQUIRED )
3162
3250
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLS , True , ssl .CERT_REQUIRED )
3163
- try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLSv1 , 'TLSv1' , ssl .CERT_REQUIRED )
3251
+ if has_tls_version ('TLSv1' ):
3252
+ try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLSv1 , 'TLSv1' , ssl .CERT_REQUIRED )
3164
3253
3165
3254
# Server with specific SSL options
3166
- if hasattr ( ssl , 'PROTOCOL_SSLv3 ' ):
3255
+ if has_tls_version ( 'SSLv3 ' ):
3167
3256
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_SSLv3 , False ,
3168
3257
server_options = ssl .OP_NO_SSLv3 )
3169
3258
# Will choose TLSv1
3170
3259
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLS , True ,
3171
3260
server_options = ssl .OP_NO_SSLv2 | ssl .OP_NO_SSLv3 )
3172
- try_protocol_combo ( ssl . PROTOCOL_TLS , ssl . PROTOCOL_TLSv1 , False ,
3173
- server_options = ssl .OP_NO_TLSv1 )
3174
-
3261
+ if has_tls_version ( 'TLSv1' ):
3262
+ try_protocol_combo ( ssl . PROTOCOL_TLS , ssl .PROTOCOL_TLSv1 , False ,
3263
+ server_options = ssl . OP_NO_TLSv1 )
3175
3264
3176
- @skip_if_broken_ubuntu_ssl
3177
- @unittest .skipUnless (hasattr (ssl , 'PROTOCOL_SSLv3' ),
3178
- "OpenSSL is compiled without SSLv3 support" )
3265
+ @requires_tls_version ('SSLv3' )
3179
3266
def test_protocol_sslv3 (self ):
3180
3267
"""Connecting to an SSLv3 server with various client options"""
3181
3268
if support .verbose :
3182
3269
sys .stdout .write ("\n " )
3183
3270
try_protocol_combo (ssl .PROTOCOL_SSLv3 , ssl .PROTOCOL_SSLv3 , 'SSLv3' )
3184
3271
try_protocol_combo (ssl .PROTOCOL_SSLv3 , ssl .PROTOCOL_SSLv3 , 'SSLv3' , ssl .CERT_OPTIONAL )
3185
3272
try_protocol_combo (ssl .PROTOCOL_SSLv3 , ssl .PROTOCOL_SSLv3 , 'SSLv3' , ssl .CERT_REQUIRED )
3186
- if hasattr ( ssl , 'PROTOCOL_SSLv2 ' ):
3273
+ if has_tls_version ( 'SSLv2 ' ):
3187
3274
try_protocol_combo (ssl .PROTOCOL_SSLv3 , ssl .PROTOCOL_SSLv2 , False )
3188
3275
try_protocol_combo (ssl .PROTOCOL_SSLv3 , ssl .PROTOCOL_TLS , False ,
3189
3276
client_options = ssl .OP_NO_SSLv3 )
@@ -3193,44 +3280,40 @@ def test_protocol_sslv3(self):
3193
3280
try_protocol_combo (ssl .PROTOCOL_SSLv3 , ssl .PROTOCOL_TLS ,
3194
3281
False , client_options = ssl .OP_NO_SSLv2 )
3195
3282
3196
- @skip_if_broken_ubuntu_ssl
3283
+ @requires_tls_version ( 'TLSv1' )
3197
3284
def test_protocol_tlsv1 (self ):
3198
3285
"""Connecting to a TLSv1 server with various client options"""
3199
3286
if support .verbose :
3200
3287
sys .stdout .write ("\n " )
3201
3288
try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_TLSv1 , 'TLSv1' )
3202
3289
try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_TLSv1 , 'TLSv1' , ssl .CERT_OPTIONAL )
3203
3290
try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_TLSv1 , 'TLSv1' , ssl .CERT_REQUIRED )
3204
- if hasattr ( ssl , 'PROTOCOL_SSLv2 ' ):
3291
+ if has_tls_version ( 'SSLv2 ' ):
3205
3292
try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_SSLv2 , False )
3206
- if hasattr ( ssl , 'PROTOCOL_SSLv3 ' ):
3293
+ if has_tls_version ( 'SSLv3 ' ):
3207
3294
try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_SSLv3 , False )
3208
3295
try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_TLS , False ,
3209
3296
client_options = ssl .OP_NO_TLSv1 )
3210
3297
3211
- @skip_if_broken_ubuntu_ssl
3212
- @unittest .skipUnless (hasattr (ssl , "PROTOCOL_TLSv1_1" ),
3213
- "TLS version 1.1 not supported." )
3298
+ @requires_tls_version ('TLSv1_1' )
3214
3299
def test_protocol_tlsv1_1 (self ):
3215
3300
"""Connecting to a TLSv1.1 server with various client options.
3216
3301
Testing against older TLS versions."""
3217
3302
if support .verbose :
3218
3303
sys .stdout .write ("\n " )
3219
3304
try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_TLSv1_1 , 'TLSv1.1' )
3220
- if hasattr ( ssl , 'PROTOCOL_SSLv2 ' ):
3305
+ if has_tls_version ( 'SSLv2 ' ):
3221
3306
try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_SSLv2 , False )
3222
- if hasattr ( ssl , 'PROTOCOL_SSLv3 ' ):
3307
+ if has_tls_version ( 'SSLv3 ' ):
3223
3308
try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_SSLv3 , False )
3224
3309
try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_TLS , False ,
3225
3310
client_options = ssl .OP_NO_TLSv1_1 )
3226
3311
3227
3312
try_protocol_combo (ssl .PROTOCOL_TLS , ssl .PROTOCOL_TLSv1_1 , 'TLSv1.1' )
3228
- try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_TLSv1 , False )
3229
- try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_TLSv1_1 , False )
3313
+ try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_TLSv1_2 , False )
3314
+ try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_TLSv1_1 , False )
3230
3315
3231
- @skip_if_broken_ubuntu_ssl
3232
- @unittest .skipUnless (hasattr (ssl , "PROTOCOL_TLSv1_2" ),
3233
- "TLS version 1.2 not supported." )
3316
+ @requires_tls_version ('TLSv1_2' )
3234
3317
def test_protocol_tlsv1_2 (self ):
3235
3318
"""Connecting to a TLSv1.2 server with various client options.
3236
3319
Testing against older TLS versions."""
@@ -3239,9 +3322,9 @@ def test_protocol_tlsv1_2(self):
3239
3322
try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_TLSv1_2 , 'TLSv1.2' ,
3240
3323
server_options = ssl .OP_NO_SSLv3 | ssl .OP_NO_SSLv2 ,
3241
3324
client_options = ssl .OP_NO_SSLv3 | ssl .OP_NO_SSLv2 ,)
3242
- if hasattr ( ssl , 'PROTOCOL_SSLv2 ' ):
3325
+ if has_tls_version ( 'SSLv2 ' ):
3243
3326
try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_SSLv2 , False )
3244
- if hasattr ( ssl , 'PROTOCOL_SSLv3 ' ):
3327
+ if has_tls_version ( 'SSLv3 ' ):
3245
3328
try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_SSLv3 , False )
3246
3329
try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_TLS , False ,
3247
3330
client_options = ssl .OP_NO_TLSv1_2 )
@@ -3684,7 +3767,7 @@ def test_version_basic(self):
3684
3767
self .assertIs (s .version (), None )
3685
3768
self .assertIs (s ._sslobj , None )
3686
3769
s .connect ((HOST , server .port ))
3687
- if IS_OPENSSL_1_1_1 and ssl . HAS_TLSv1_3 :
3770
+ if IS_OPENSSL_1_1_1 and has_tls_version ( 'TLSv1_3' ) :
3688
3771
self .assertEqual (s .version (), 'TLSv1.3' )
3689
3772
elif ssl .OPENSSL_VERSION_INFO >= (1 , 0 , 2 ):
3690
3773
self .assertEqual (s .version (), 'TLSv1.2' )
@@ -3693,8 +3776,7 @@ def test_version_basic(self):
3693
3776
self .assertIs (s ._sslobj , None )
3694
3777
self .assertIs (s .version (), None )
3695
3778
3696
- @unittest .skipUnless (ssl .HAS_TLSv1_3 ,
3697
- "test requires TLSv1.3 enabled OpenSSL" )
3779
+ @requires_tls_version ('TLSv1_3' )
3698
3780
def test_tls1_3 (self ):
3699
3781
context = ssl .SSLContext (ssl .PROTOCOL_TLS )
3700
3782
context .load_cert_chain (CERTFILE )
@@ -3711,9 +3793,9 @@ def test_tls1_3(self):
3711
3793
})
3712
3794
self .assertEqual (s .version (), 'TLSv1.3' )
3713
3795
3714
- @unittest . skipUnless ( hasattr ( ssl . SSLContext , 'minimum_version' ),
3715
- "required OpenSSL 1.1.0g" )
3716
- def test_min_max_version (self ):
3796
+ @requires_minimum_version
3797
+ @ requires_tls_version ( 'TLSv1_2' )
3798
+ def test_min_max_version_tlsv1_2 (self ):
3717
3799
client_context , server_context , hostname = testing_context ()
3718
3800
# client TLSv1.0 to 1.2
3719
3801
client_context .minimum_version = ssl .TLSVersion .TLSv1
@@ -3728,7 +3810,13 @@ def test_min_max_version(self):
3728
3810
s .connect ((HOST , server .port ))
3729
3811
self .assertEqual (s .version (), 'TLSv1.2' )
3730
3812
3813
+ @requires_minimum_version
3814
+ @requires_tls_version ('TLSv1_1' )
3815
+ def test_min_max_version_tlsv1_1 (self ):
3816
+ client_context , server_context , hostname = testing_context ()
3731
3817
# client 1.0 to 1.2, server 1.0 to 1.1
3818
+ client_context .minimum_version = ssl .TLSVersion .TLSv1
3819
+ client_context .maximum_version = ssl .TLSVersion .TLSv1_2
3732
3820
server_context .minimum_version = ssl .TLSVersion .TLSv1
3733
3821
server_context .maximum_version = ssl .TLSVersion .TLSv1_1
3734
3822
@@ -3738,6 +3826,10 @@ def test_min_max_version(self):
3738
3826
s .connect ((HOST , server .port ))
3739
3827
self .assertEqual (s .version (), 'TLSv1.1' )
3740
3828
3829
+ @requires_minimum_version
3830
+ @requires_tls_version ('TLSv1_2' )
3831
+ def test_min_max_version_mismatch (self ):
3832
+ client_context , server_context , hostname = testing_context ()
3741
3833
# client 1.0, server 1.2 (mismatch)
3742
3834
server_context .minimum_version = ssl .TLSVersion .TLSv1_2
3743
3835
server_context .maximum_version = ssl .TLSVersion .TLSv1_2
@@ -3750,10 +3842,8 @@ def test_min_max_version(self):
3750
3842
s .connect ((HOST , server .port ))
3751
3843
self .assertIn ("alert" , str (e .exception ))
3752
3844
3753
-
3754
- @unittest .skipUnless (hasattr (ssl .SSLContext , 'minimum_version' ),
3755
- "required OpenSSL 1.1.0g" )
3756
- @unittest .skipUnless (ssl .HAS_SSLv3 , "requires SSLv3 support" )
3845
+ @requires_minimum_version
3846
+ @requires_tls_version ('SSLv3' )
3757
3847
def test_min_max_version_sslv3 (self ):
3758
3848
client_context , server_context , hostname = testing_context ()
3759
3849
server_context .minimum_version = ssl .TLSVersion .SSLv3
@@ -4272,7 +4362,7 @@ def test_session_handling(self):
4272
4362
'Session refers to a different SSLContext.' )
4273
4363
4274
4364
4275
- @unittest .skipUnless (ssl . HAS_TLSv1_3 , "Test needs TLS 1.3" )
4365
+ @unittest .skipUnless (has_tls_version ( 'TLSv1_3' ) , "Test needs TLS 1.3" )
4276
4366
class TestPostHandshakeAuth (unittest .TestCase ):
4277
4367
def test_pha_setter (self ):
4278
4368
protocols = [
0 commit comments