From 7689ac7bed697cebf19be5e1932f5d7e5f47744a Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Fri, 30 Aug 2019 11:15:56 -0400 Subject: [PATCH] disable ssl verify on time sync so we know when clock is WAY off --- src/gam.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gam.py b/src/gam.py index 1d459acb..3c34faaa 100755 --- a/src/gam.py +++ b/src/gam.py @@ -723,7 +723,12 @@ def SetGlobalVariables(): def getLocalGoogleTimeOffset(testLocation='www.googleapis.com'): localUTC = datetime.datetime.now(datetime.timezone.utc) try: - googleUTC = dateutil.parser.parse(_createHttpObj().request('https://'+testLocation, 'HEAD')[0]['date']) + # we disable SSL verify so we can still get time even if clock + # is way off. This could be spoofed / MitM but we'll fail for those + # situations everywhere else but here. + badhttp = _createHttpObj() + badhttp.disable_ssl_certificate_validation = True + googleUTC = dateutil.parser.parse(badhttp.request('https://'+testLocation, 'HEAD')[0]['date']) offset = abs(localUTC-googleUTC).total_seconds() days, remainder = divmod(offset, 86400) hours, remainder = divmod(remainder, 3600)