aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-10-11 11:36:05 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-10-11 11:36:05 -0500
commit1ec38f6c1ca84014646d760754482ad7467f5b17 (patch)
tree5997643f12385f8fdc79db64597500b20978e5dc /src
parent450d9797a2320f85aff317e5cab39cc2339eabec (diff)
parent79bee4ac1bed42e8df47dcaa11c83e1a55bd0b6f (diff)
downloadcryptography-1ec38f6c1ca84014646d760754482ad7467f5b17.tar.gz
cryptography-1ec38f6c1ca84014646d760754482ad7467f5b17.tar.bz2
cryptography-1ec38f6c1ca84014646d760754482ad7467f5b17.zip
Merge pull request #2405 from alex/unkonwn-public-key
Fixed #2404 -- handle a certificate with an unknown public key
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/x509.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py
index 80f32e29..cfde4a73 100644
--- a/src/cryptography/hazmat/backends/openssl/x509.py
+++ b/src/cryptography/hazmat/backends/openssl/x509.py
@@ -260,7 +260,11 @@ class _Certificate(object):
def public_key(self):
pkey = self._backend._lib.X509_get_pubkey(self._x509)
- self._backend.openssl_assert(pkey != self._backend._ffi.NULL)
+ if pkey == self._backend._ffi.NULL:
+ # Remove errors from the stack.
+ self._backend._consume_errors()
+ raise ValueError("Certificate public key is of an unknown type")
+
pkey = self._backend._ffi.gc(pkey, self._backend._lib.EVP_PKEY_free)
return self._backend._evp_pkey_to_public_key(pkey)