diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-12-15 16:27:36 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-12-15 16:27:36 -0600 |
commit | 233f911c2ee46f3d9cdf7b15c6ccc3cc79552a9a (patch) | |
tree | 35040d8c86b56535b4cec51f27c8a9ec94d71cd0 | |
parent | 92aac3891715aea562ffb51985bd142cbabb64ce (diff) | |
download | cryptography-233f911c2ee46f3d9cdf7b15c6ccc3cc79552a9a.tar.gz cryptography-233f911c2ee46f3d9cdf7b15c6ccc3cc79552a9a.tar.bz2 cryptography-233f911c2ee46f3d9cdf7b15c6ccc3cc79552a9a.zip |
revert asn1 time parsing to avoid locale problems
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/x509.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py index 26c5edc2..01055c5f 100644 --- a/src/cryptography/hazmat/backends/openssl/x509.py +++ b/src/cryptography/hazmat/backends/openssl/x509.py @@ -96,8 +96,17 @@ class _Certificate(object): return self._parse_asn1_time(asn1_time) def _parse_asn1_time(self, asn1_time): - bio = self._backend._create_mem_bio() - res = self._backend._lib.ASN1_TIME_print(bio, asn1_time) - assert res == 1 - time = self._backend._read_mem_bio(bio).decode("ascii") - return datetime.datetime.strptime(time, "%b %d %H:%M:%S %Y GMT") + assert asn1_time != self._backend._ffi.NULL + generalized_time = self._backend._lib.ASN1_TIME_to_generalizedtime( + asn1_time, self._backend._ffi.NULL + ) + assert generalized_time != self._backend._ffi.NULL + generalized_time = self._backend._ffi.gc( + generalized_time, self._backend._lib.ASN1_GENERALIZEDTIME_free + ) + time = self._backend._ffi.string( + self._backend._lib.ASN1_STRING_data( + self._backend._ffi.cast("ASN1_STRING *", generalized_time) + ) + ).decode("ascii") + return datetime.datetime.strptime(time, "%Y%m%d%H%M%SZ") |