From 839f02662e138ed3cbfa6f155a8b79eaeac696e5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 25 Apr 2014 02:18:54 -0400 Subject: [PATCH] Check before using ssl.create_default_context --- scripts/mailtest | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/mailtest b/scripts/mailtest index 9403ff2..e6d1595 100755 --- a/scripts/mailtest +++ b/scripts/mailtest @@ -36,6 +36,10 @@ def do_tls(conn, sslv): # Possible values of smtp_sslv: none|peer|client_once|fail_if_no_peer_cert try: # Creating a context with the purpose of server authentication implies verifying the certificate + if not hasattr(ssl,'create_default_context'): + # ssl.create_default_context is in Pyton 3.4+ + print_warn('WARNING: cannot verify server certificate') + return conn.starttls() sslcontext=ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH) # The None below looks like might be a typo but it's not - it represents the ActiveRecord default (to verify) if sslv in (None, 'peer', 'client_once', 'fail_if_no_peer_cert'): -- 2.25.1