1313import shutil
1414import ssl
1515import stat
16+ import sys
1617import tempfile
1718import textwrap
1819import unittest
@@ -1340,13 +1341,13 @@ async def verify_fails(sslmode, *, host='localhost', exn_type):
13401341await verify_works ('allow' )
13411342await verify_works ('prefer' )
13421343await verify_fails ('require' ,
1343- exn_type = ssl .CertificateError )
1344+ exn_type = ssl .SSLError )
13441345await verify_fails ('verify-ca' ,
1345- exn_type = ssl .CertificateError )
1346+ exn_type = ssl .SSLError )
13461347await verify_fails ('verify-ca' , host = '127.0.0.1' ,
1347- exn_type = ssl .CertificateError )
1348+ exn_type = ssl .SSLError )
13481349await verify_fails ('verify-full' ,
1349- exn_type = ssl .CertificateError )
1350+ exn_type = ssl .SSLError )
13501351
13511352async def test_ssl_connection_default_context (self ):
13521353# XXX: uvloop artifact
@@ -1410,6 +1411,9 @@ async def test_executemany_uvloop_ssl_issue_700(self):
14101411finally :
14111412await con .close ()
14121413
1414+ @unittest .skipIf (
1415+ sys .version_info < (3 , 7 ), "Python < 3.7 doesn't have ssl.TLSVersion"
1416+ )
14131417async def test_tls_version (self ):
14141418# XXX: uvloop artifact
14151419old_handler = self .loop .get_exception_handler ()
@@ -1420,7 +1424,7 @@ async def test_tls_version(self):
14201424dsn = 'postgresql://ssl_user@localhost/postgres'
14211425'?sslmode=require&ssl_min_protocol_version=TLSv1.3'
14221426 )
1423- with self .assertRaisesRegex (ssl .SSLError , 'protocol version' ):
1427+ with self .assertRaises (ssl .SSLError ):
14241428await self .connect (
14251429dsn = 'postgresql://ssl_user@localhost/postgres'
14261430'?sslmode=require'
0 commit comments