From 978137d89e99314e823ab206d482d23e6a830329 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 8 Jul 2015 20:59:16 -0400 Subject: Fixed #2127 -- added __hash__ to CSR --- src/cryptography/hazmat/backends/openssl/x509.py | 3 +++ src/cryptography/x509.py | 6 ++++++ 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py index 68104e69..a4013389 100644 --- a/src/cryptography/hazmat/backends/openssl/x509.py +++ b/src/cryptography/hazmat/backends/openssl/x509.py @@ -709,6 +709,9 @@ class _CertificateSigningRequest(object): def __ne__(self, other): return not self == other + def __hash__(self): + return hash(self.public_bytes(serialization.Encoding.DER)) + 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 f8134958..0ad1d4f9 100644 --- a/src/cryptography/x509.py +++ b/src/cryptography/x509.py @@ -1409,6 +1409,12 @@ class CertificateSigningRequest(object): Checks not equal. """ + @abc.abstractmethod + def __hash__(self): + """ + Computes a hash. + """ + @abc.abstractmethod def public_key(self): """ -- cgit v1.2.3