Skip to content

Fix SSL compatibility of libpq #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add TLS version test
  • Loading branch information
fantix committed Sep 14, 2021
commit 3ffdde5d9318992cc6b2bf6e9c09329a51f4234f
38 changes: 38 additions & 0 deletions tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,8 @@ def get_server_settings(cls):
'ssl_cert_file': SSL_CERT_FILE,
'ssl_key_file': SSL_KEY_FILE,
'ssl_ca_file': CLIENT_CA_CERT_FILE,
'ssl_min_protocol_version': 'TLSv1.2',
'ssl_max_protocol_version': 'TLSv1.2',
})

return conf
Expand Down Expand Up @@ -1408,6 +1410,42 @@ async def test_executemany_uvloop_ssl_issue_700(self):
finally:
await con.close()

async def test_tls_version(self):
# XXX: uvloop artifact
old_handler = self.loop.get_exception_handler()
try:
self.loop.set_exception_handler(lambda *args: None)
with self.assertRaisesRegex(ssl.SSLError, 'protocol version'):
await self.connect(
dsn='postgresql://ssl_user@localhost/postgres'
'?sslmode=require&ssl_min_protocol_version=TLSv1.3'
)
with self.assertRaisesRegex(ssl.SSLError, 'protocol version'):
await self.connect(
dsn='postgresql://ssl_user@localhost/postgres'
'?sslmode=require'
'&ssl_min_protocol_version=TLSv1.1'
'&ssl_max_protocol_version=TLSv1.1'
)
with self.assertRaisesRegex(ssl.SSLError, 'no protocols'):
await self.connect(
dsn='postgresql://ssl_user@localhost/postgres'
'?sslmode=require'
'&ssl_min_protocol_version=TLSv1.2'
'&ssl_max_protocol_version=TLSv1.1'
)
con = await self.connect(
dsn='postgresql://ssl_user@localhost/postgres?sslmode=require'
'&ssl_min_protocol_version=TLSv1.2'
'&ssl_max_protocol_version=TLSv1.2'
)
try:
self.assertEqual(await con.fetchval('SELECT 42'), 42)
finally:
await con.close()
finally:
self.loop.set_exception_handler(old_handler)


@unittest.skipIf(os.environ.get('PGHOST'), 'unmanaged cluster')
class TestClientSSLConnection(BaseTestSSLConnection):
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy