aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-12-11 14:54:48 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-12-15 15:49:49 -0600
commitb2de948b18316ac5f08b22d1ab22bdd49da9cc5f (patch)
tree5b882dbc9cc18af972f682ab87aa4f19a3c8035b /src
parent68481c3e78d08b7defdd716b72b7563fb0ee5469 (diff)
downloadcryptography-b2de948b18316ac5f08b22d1ab22bdd49da9cc5f.tar.gz
cryptography-b2de948b18316ac5f08b22d1ab22bdd49da9cc5f.tar.bz2
cryptography-b2de948b18316ac5f08b22d1ab22bdd49da9cc5f.zip
reorganize a bunch of things related to the x509certificate interface
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/x509.py4
-rw-r--r--src/cryptography/x509.py42
2 files changed, 44 insertions, 2 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py
index 532785ac..35313b25 100644
--- a/src/cryptography/hazmat/backends/openssl/x509.py
+++ b/src/cryptography/hazmat/backends/openssl/x509.py
@@ -16,10 +16,10 @@ from __future__ import absolute_import, division, print_function
import datetime
from cryptography import utils, x509
-from cryptography.hazmat.primitives import hashes, interfaces
+from cryptography.hazmat.primitives import hashes
-@utils.register_interface(interfaces.X509Certificate)
+@utils.register_interface(x509.X509Certificate)
class _X509Certificate(object):
def __init__(self, backend, x509):
self._backend = backend
diff --git a/src/cryptography/x509.py b/src/cryptography/x509.py
index 191666e6..ed754cbc 100644
--- a/src/cryptography/x509.py
+++ b/src/cryptography/x509.py
@@ -4,8 +4,11 @@
from __future__ import absolute_import, division, print_function
+import abc
from enum import Enum
+import six
+
class X509Version(Enum):
v1 = 0
@@ -22,3 +25,42 @@ def load_der_x509_certificate(data, backend):
class InvalidX509Version(Exception):
pass
+
+
+@six.add_metaclass(abc.ABCMeta)
+class X509Certificate(object):
+ @abc.abstractmethod
+ def fingerprint(self, algorithm):
+ """
+ Returns bytes using digest passed.
+ """
+
+ @abc.abstractproperty
+ def serial(self):
+ """
+ Returns certificate serial number
+ """
+
+ @abc.abstractproperty
+ def version(self):
+ """
+ Returns the certificate version
+ """
+
+ @abc.abstractmethod
+ def public_key(self):
+ """
+ Returns the public key
+ """
+
+ @abc.abstractproperty
+ def not_valid_before(self):
+ """
+ Not before time (represented as UTC datetime)
+ """
+
+ @abc.abstractproperty
+ def not_valid_after(self):
+ """
+ Not after time (represented as UTC datetime)
+ """