aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-07-06 21:02:54 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2015-07-06 21:02:54 -0400
commit70c8f8b4d96f6a26f016e43d61005ad12027cc1e (patch)
tree44214bc67caadbccf7759133965ec2db3682349e /src
parent11bd1a13627098468707177a1e1fddfc92601ff3 (diff)
downloadcryptography-70c8f8b4d96f6a26f016e43d61005ad12027cc1e.tar.gz
cryptography-70c8f8b4d96f6a26f016e43d61005ad12027cc1e.tar.bz2
cryptography-70c8f8b4d96f6a26f016e43d61005ad12027cc1e.zip
Fixed #2121 -- added __eq__ and __ne__ to CSRs
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/x509.py8
-rw-r--r--src/cryptography/x509.py12
2 files changed, 20 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py
index 7bfeb2ce..d49147ad 100644
--- a/src/cryptography/hazmat/backends/openssl/x509.py
+++ b/src/cryptography/hazmat/backends/openssl/x509.py
@@ -701,6 +701,14 @@ class _CertificateSigningRequest(object):
self._backend = backend
self._x509_req = x509_req
+ def __eq__(self, other):
+ if not isinstance(other, _CertificateSigningRequest):
+ return NotImplemented
+
+ self_bytes = self.public_bytes(serialization.Encoding.DER)
+ other_bytes = other.public_bytes(serialization.Encoding.DER)
+ return self_bytes == other_bytes
+
def public_key(self):
pkey = self._backend._lib.X509_REQ_get_pubkey(self._x509_req)
assert pkey != self._backend._ffi.NULL
diff --git a/src/cryptography/x509.py b/src/cryptography/x509.py
index afd28f20..b36258a4 100644
--- a/src/cryptography/x509.py
+++ b/src/cryptography/x509.py
@@ -1391,6 +1391,18 @@ class CertificateRevocationList(object):
@six.add_metaclass(abc.ABCMeta)
class CertificateSigningRequest(object):
+ @abc.abstracmethod
+ def __eq__(self, other):
+ """
+ Checks equality.
+ """
+
+ @abc.abstractmethod
+ def __ne__(self, other):
+ """
+ Checks not equal.
+ """
+
@abc.abstractmethod
def public_key(self):
"""