This repository has been archived by the owner on Feb 19, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove two-digit-year variants from certificate validity date decodin…
…g. Fixes Issue #461
- Loading branch information
1c259fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix is just reversing the problem it seems.
Before, it only worked when the time format returned by getComponent() was 'utcTime' (2 digit year)
Now, it only works when the time format returned by getComponent() is 'generalTime' (4 digit year)
tomstarstuck suggested using asDateTime:
not_before = not_before.getComponent().asDateTime
not_before = not_before.astimezone(pytz.UTC).replace(tzinfo = None)
This worked for me:
not_before_is_gt = not_before.getName() == 'generalTime'
not_before = str(not_before.getComponent())
if not_before_is_gt: not_before = datetime.strptime(not_before, '%Y%m%d%H%M%SZ')
...
Of course, milage may depend on which version of pyasn1 one is using...