mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 21:01:36 +00:00
disable ssl verify on time sync so we know when clock is WAY off
This commit is contained in:
@@ -723,7 +723,12 @@ def SetGlobalVariables():
|
|||||||
def getLocalGoogleTimeOffset(testLocation='www.googleapis.com'):
|
def getLocalGoogleTimeOffset(testLocation='www.googleapis.com'):
|
||||||
localUTC = datetime.datetime.now(datetime.timezone.utc)
|
localUTC = datetime.datetime.now(datetime.timezone.utc)
|
||||||
try:
|
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()
|
offset = abs(localUTC-googleUTC).total_seconds()
|
||||||
days, remainder = divmod(offset, 86400)
|
days, remainder = divmod(offset, 86400)
|
||||||
hours, remainder = divmod(remainder, 3600)
|
hours, remainder = divmod(remainder, 3600)
|
||||||
|
|||||||
Reference in New Issue
Block a user