summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2016-01-21 12:57:37 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2016-01-21 12:57:37 -0600
commitfde45c99bd76f8889497f61a2bfaf6160dc26b47 (patch)
tree7187000d2d1cb338ea1f17b38e7feac3e16613df
parent8acb3af69d114ba438aab702a0318d1a8620e424 (diff)
downloadpyopenssl-git-fde45c99bd76f8889497f61a2bfaf6160dc26b47.tar.gz
compare datetimes directly for the expiry check
-rw-r--r--src/OpenSSL/crypto.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index 56dad18..a00b5c0 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -1,6 +1,5 @@
import datetime
-from time import mktime
from base64 import b16encode
from functools import partial
from operator import __eq__, __ne__, __lt__, __le__, __gt__, __ge__
@@ -1213,11 +1212,9 @@ class X509(object):
:rtype: :py:class:`bool`
"""
time_string = _native(self.get_notAfter())
- timestamp = mktime(datetime.datetime.strptime(
- time_string, "%Y%m%d%H%M%SZ").timetuple())
- now = mktime(datetime.datetime.utcnow().timetuple())
+ not_after = datetime.datetime.strptime(time_string, "%Y%m%d%H%M%SZ")
- return timestamp < now
+ return not_after < datetime.datetime.utcnow()
def _get_boundary_time(self, which):
return _get_asn1_time(which(self._x509))