From f0d0345fcdf0309219bdd3b763658dad2cafa9ad Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Tue, 23 Apr 2019 10:31:10 -0400 Subject: [PATCH] 'gam version extended' to show OpenSSL version, TLS used --- src/gam.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gam.py b/src/gam.py index f87306f0..4188b764 100755 --- a/src/gam.py +++ b/src/gam.py @@ -669,6 +669,7 @@ def doGAMCheckForUpdates(forceCheck=False): def doGAMVersion(checkForArgs=True): force_check = False simple = False + extended = False if checkForArgs: i = 2 while i < len(sys.argv): @@ -679,6 +680,9 @@ def doGAMVersion(checkForArgs=True): elif myarg == 'simple': simple = True i += 1 + elif myarg == 'extended': + extended = True + i += 1 else: systemErrorExit(2, '%s is not a valid argument for "gam version"' % sys.argv[i]) if simple: @@ -691,6 +695,16 @@ def doGAMVersion(checkForArgs=True): platform.machine(), GM_Globals[GM_GAM_PATH])) if force_check: doGAMCheckForUpdates(forceCheck=True) + if extended: + import ssl, socket, importlib + print(ssl.OPENSSL_VERSION) + proot = os.path.dirname(importlib.import_module('httplib2').__file__) + ca_path = os.path.join(proot, 'cacerts.txt') + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + ssl_sock = ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE, ca_certs=ca_path) + ssl_sock.connect(('www.googleapis.com', 443)) + cipher_name, tls_ver, _ = ssl_sock.cipher() + print('www.googleapis.com connects using %s %s' % (tls_ver, cipher_name)) def handleOAuthTokenError(e, soft_errors): if e.replace('.', '') in OAUTH2_TOKEN_ERRORS or e.startswith('Invalid response'):