Check that header was not signed in the future

master
Bob Mottram 2019-08-23 12:37:34 +01:00
parent a2e3208999
commit f0cc2359ad
1 changed files with 7 additions and 2 deletions

View File

@ -126,9 +126,14 @@ def verifyRecentSignature(signedDateStr: str) -> bool:
currDate=datetime.datetime.utcnow() currDate=datetime.datetime.utcnow()
signedDate=datetime.datetime.strptime(signedDateStr,"%a, %d %b %Y %H:%M:%S %Z") signedDate=datetime.datetime.strptime(signedDateStr,"%a, %d %b %Y %H:%M:%S %Z")
# 12 hours tollerance # 12 hours tollerance
if (currDate-signedDate).seconds > 43200: timeDiffSec=(currDate-signedDate).seconds
if timeDiffSec > 43200:
print('WARN: Header signed too long ago: '+signedDateStr) print('WARN: Header signed too long ago: '+signedDateStr)
print(str((currDate-signedDate).seconds/(60*60))+' hours') print(str(timeDiffSec/(60*60))+' hours')
return False
if timeDiffSec < 0:
print('WARN: Header signed in the future! '+signedDateStr)
print(str(timeDiffSec/(60*60))+' hours')
return False return False
return True return True