@@ -1180,11 +1180,11 @@ def test_load_cert_chain(self):
1180
1180
# Mismatching key and cert
1181
1181
ctx = ssl .SSLContext (ssl .PROTOCOL_TLS_SERVER )
1182
1182
# Allow for flexible libssl error messages.
1183
- regex = "("
1184
- regex += " key values mismatch" # OpenSSL
1185
- regex += "|"
1186
- regex += " KEY_VALUES_MISMATCH" # AWS-LC
1187
- regex += ")"
1183
+ regex = re . compile ( r"""(
1184
+ key values mismatch # OpenSSL
1185
+ |
1186
+ KEY_VALUES_MISMATCH # AWS-LC
1187
+ )""" , re . X )
1188
1188
with self .assertRaisesRegex (ssl .SSLError , regex ):
1189
1189
ctx .load_cert_chain (CAFILE_CACERT , ONLYKEY )
1190
1190
# Password protected key and cert
@@ -1841,11 +1841,11 @@ def test_connect_fail(self):
1841
1841
cert_reqs = ssl .CERT_REQUIRED )
1842
1842
self .addCleanup (s .close )
1843
1843
# Allow for flexible libssl error messages.
1844
- regex = "("
1845
- regex += " certificate verify failed" # OpenSSL
1846
- regex += "|"
1847
- regex += "CERTIFICATE_VERIFY_FAILED" # AWS-LC
1848
- regex += ")"
1844
+ regex = re . compile ( r"""(
1845
+ certificate verify failed # OpenSSL
1846
+ |
1847
+ CERTIFICATE_VERIFY_FAILED # AWS-LC
1848
+ )""" , re . X )
1849
1849
self .assertRaisesRegex (ssl .SSLError , regex ,
1850
1850
s .connect , self .server_addr )
1851
1851
@@ -1915,11 +1915,11 @@ def test_connect_with_context_fail(self):
1915
1915
)
1916
1916
self .addCleanup (s .close )
1917
1917
# Allow for flexible libssl error messages.
1918
- regex = "("
1919
- regex += " certificate verify failed" # OpenSSL
1920
- regex += "|"
1921
- regex += "CERTIFICATE_VERIFY_FAILED" # AWS-LC
1922
- regex += ")"
1918
+ regex = re . compile ( r"""(
1919
+ certificate verify failed # OpenSSL
1920
+ |
1921
+ CERTIFICATE_VERIFY_FAILED # AWS-LC
1922
+ )""" , re . X )
1923
1923
self .assertRaisesRegex (ssl .SSLError , regex ,
1924
1924
s .connect , self .server_addr )
1925
1925
@@ -2872,11 +2872,11 @@ def test_crl_check(self):
2872
2872
2873
2873
server = ThreadedEchoServer (context = server_context , chatty = True )
2874
2874
# Allow for flexible libssl error messages.
2875
- regex = "("
2876
- regex += " certificate verify failed" # OpenSSL
2877
- regex += "|"
2878
- regex += "CERTIFICATE_VERIFY_FAILED" # AWS-LC
2879
- regex += ")"
2875
+ regex = re . compile ( r"""(
2876
+ certificate verify failed # OpenSSL
2877
+ |
2878
+ CERTIFICATE_VERIFY_FAILED # AWS-LC
2879
+ )""" , re . X )
2880
2880
with server :
2881
2881
with client_context .wrap_socket (socket .socket (),
2882
2882
server_hostname = hostname ) as s :
@@ -2912,11 +2912,11 @@ def test_check_hostname(self):
2912
2912
# incorrect hostname should raise an exception
2913
2913
server = ThreadedEchoServer (context = server_context , chatty = True )
2914
2914
# Allow for flexible libssl error messages.
2915
- regex = "("
2916
- regex += "Hostname mismatch, certificate is not valid" # OpenSSL
2917
- regex += "|"
2918
- regex += "CERTIFICATE_VERIFY_FAILED" # AWS-LC
2919
- regex += ")"
2915
+ regex = re . compile ( r"""(
2916
+ certificate verify failed # OpenSSL
2917
+ |
2918
+ CERTIFICATE_VERIFY_FAILED # AWS-LC
2919
+ )""" , re . X )
2920
2920
with server :
2921
2921
with client_context .wrap_socket (socket .socket (),
2922
2922
server_hostname = "invalid" ) as s :
@@ -3195,13 +3195,13 @@ def test_ssl_cert_verify_error(self):
3195
3195
self .assertEqual (e .verify_code , 20 )
3196
3196
self .assertEqual (e .verify_message , msg )
3197
3197
# Allow for flexible libssl error messages.
3198
- regex = "(" + msg + " |CERTIFICATE_VERIFY_FAILED)"
3198
+ regex = f"( { msg } |CERTIFICATE_VERIFY_FAILED)"
3199
3199
self .assertRegex (repr (e ), regex )
3200
- regex = "("
3201
- regex += " certificate verify failed" # OpenSSL
3202
- regex += "|"
3203
- regex += "CERTIFICATE_VERIFY_FAILED" # AWS-LC
3204
- regex += ")"
3200
+ regex = re . compile ( r"""(
3201
+ certificate verify failed # OpenSSL
3202
+ |
3203
+ CERTIFICATE_VERIFY_FAILED # AWS-LC
3204
+ )""" , re . X )
3205
3205
self .assertRegex (repr (e ), regex )
3206
3206
3207
3207
def test_PROTOCOL_TLS (self ):
0 commit comments