aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/x509.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py
index 8dced83b..9f12da0e 100644
--- a/src/cryptography/hazmat/backends/openssl/x509.py
+++ b/src/cryptography/hazmat/backends/openssl/x509.py
@@ -16,7 +16,7 @@ from __future__ import absolute_import, division, print_function
import datetime
from cryptography import utils
-from cryptography.hazmat.primitives import hashes, interfaces
+from cryptography.hazmat.primitives import hashes, interfaces, x509
@utils.register_interface(interfaces.X509Certificate)
@@ -53,6 +53,16 @@ class _X509Certificate(object):
return h.finalize()
@property
+ def version(self):
+ version = self._backend._lib.X509_get_version(self._x509)
+ if version == 0:
+ return x509.X509Version.v1
+ elif version == 2:
+ return x509.X509Version.v3
+ else:
+ raise StandardError("TODO")
+
+ @property
def serial(self):
asn1_int = self._backend._lib.X509_get_serialNumber(self._x509)
assert asn1_int != self._backend._ffi.NULL