diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-04-28 18:57:36 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-04-28 18:57:36 (GMT) |
commit | c695c95626ad776e3e378a376a7752c2bd039326 (patch) | |
tree | 3480d10a7c7165ab63c9880c3138501db69ebd6a /Doc | |
parent | 3a74ce2088e5e29d81dd672038aef7204c82947b (diff) | |
download | cpython-c695c95626ad776e3e378a376a7752c2bd039326.zip cpython-c695c95626ad776e3e378a376a7752c2bd039326.tar.gz cpython-c695c95626ad776e3e378a376a7752c2bd039326.tar.bz2 |
Issue #19940: ssl.cert_time_to_seconds() now interprets the given time string in the UTC timezone (as specified in RFC 5280), not the local timezone.
Patch by Akira.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/ssl.rst | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst index 422cf56..79cbbdc 100644 --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -372,20 +372,32 @@ Certificate handling IDN A-labels such as ``www*.xn--pthon-kva.org`` are still supported, but ``x*.python.org`` no longer matches ``xn--tda.python.org``. -.. function:: cert_time_to_seconds(timestring) +.. function:: cert_time_to_seconds(cert_time) - Returns a floating-point value containing a normal seconds-after-the-epoch - time value, given the time-string representing the "notBefore" or "notAfter" - date from a certificate. + Return the time in seconds since the Epoch, given the ``cert_time`` + string representing the "notBefore" or "notAfter" date from a + certificate in ``"%b %d %H:%M:%S %Y %Z"`` strptime format (C + locale). - Here's an example:: + Here's an example: - >>> import ssl - >>> ssl.cert_time_to_seconds("May 9 00:00:00 2007 GMT") - 1178694000.0 - >>> import time - >>> time.ctime(ssl.cert_time_to_seconds("May 9 00:00:00 2007 GMT")) - 'Wed May 9 00:00:00 2007' + .. doctest:: newcontext + + >>> import ssl + >>> timestamp = ssl.cert_time_to_seconds("Jan 5 09:34:43 2018 GMT") + >>> timestamp + 1515144883 + >>> from datetime import datetime + >>> print(datetime.utcfromtimestamp(timestamp)) + 2018-01-05 09:34:43 + + "notBefore" or "notAfter" dates must use GMT (:rfc:`5280`). + + .. versionchanged:: 3.5 + Interpret the input time as a time in UTC as specified by 'GMT' + timezone in the input string. Local timezone was used + previously. Return an integer (no fractions of a second in the + input format) .. function:: get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None) |