From 66bbfc4141ff3a4f9f2bfc517c6972b5ee6e307c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarjei=20Hus=C3=B8y?= Date: Mon, 30 May 2016 10:01:39 -0700 Subject: [PATCH] Pick best available protocol on server --- postgres_mitm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/postgres_mitm.py b/postgres_mitm.py index 45eb21e..08c9e7b 100644 --- a/postgres_mitm.py +++ b/postgres_mitm.py @@ -126,7 +126,11 @@ class ClientConnection(threading.Thread): def __init__(self, client_socket, target_backend): super(ClientConnection, self).__init__() - self.ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) + for proto in ('PROTOCOL_TLSv1_2', 'PROTOCOL_TLSv1', 'PROTOCOL_SSLv23'): + protocol = getattr(ssl, proto, None) + if protocol: + break + self.ssl_context = ssl.SSLContext(protocol) self.ssl_context.load_cert_chain(certfile='server.cert', keyfile='server.key') self.socket = client_socket self.target_backend = target_backend