summaryrefslogtreecommitdiff
path: root/src/OpenSSL/crypto.py
diff options
context:
space:
mode:
authorThomas Sileo <tsileo@users.noreply.github.com>2016-11-22 18:13:30 +0100
committerHynek Schlawack <hs@ox.cx>2016-11-22 18:13:30 +0100
commite15e60a587efcddd61e391a8e5917291c98d554e (patch)
tree06ce1ac56ad303438193696b606411559af07a69 /src/OpenSSL/crypto.py
parent33675f90f18cb8e926fccb13a1e60e900d56f7ff (diff)
downloadpyopenssl-git-e15e60a587efcddd61e391a8e5917291c98d554e.tar.gz
Add the ability to set a custom verification time on X509Store (#567)
Diffstat (limited to 'src/OpenSSL/crypto.py')
-rw-r--r--src/OpenSSL/crypto.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index 79440d7..3c8b26b 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -1520,6 +1520,28 @@ class X509Store(object):
"""
_openssl_assert(_lib.X509_STORE_set_flags(self._store, flags) != 0)
+ def set_time(self, vfy_time):
+ """
+ Set the time against which the certificates are verified.
+
+ Normally the current time is used.
+
+ .. note::
+
+ For example, you can determine if a certificate was valid at a given
+ time.
+
+ .. versionadded:: 16.3.0
+
+ :param datetime vfy_time: The verification time to set on this store.
+ :return: ``None`` if the verification time was successfully set.
+ """
+ param = _lib.X509_VERIFY_PARAM_new()
+ param = _ffi.gc(param, _lib.X509_VERIFY_PARAM_free)
+
+ _lib.X509_VERIFY_PARAM_set_time(param, int(vfy_time.strftime('%s')))
+ _openssl_assert(_lib.X509_STORE_set1_param(self._store, param) != 0)
+
X509StoreType = X509Store