fix a small bug with load_publickey (#481)
* fix a small bug with load_publickey
* update docstring, rename test method
* make hynek happy
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index 21bdadd..4c1ce87 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -2450,6 +2450,7 @@
pkey = PKey.__new__(PKey)
pkey._pkey = _ffi.gc(evp_pkey, _lib.EVP_PKEY_free)
+ pkey._only_public = True
return pkey
diff --git a/tests/test_crypto.py b/tests/test_crypto.py
index 136af0a..b5ad97a 100644
--- a/tests/test_crypto.py
+++ b/tests/test_crypto.py
@@ -2427,6 +2427,20 @@
return output
+class TestFunctions(object):
+ """
+ py.test-based tests for the free functions in the crypto module.
+
+ If possible, add new tests here.
+ """
+ def test_load_publickey_sets_only_public(self):
+ """
+ _only_public should be set on PKeys loaded with load_publickey.
+ """
+ key = load_publickey(FILETYPE_PEM, cleartextPublicKeyPEM)
+ assert key._only_public is True
+
+
class FunctionTests(TestCase):
"""
Tests for free-functions in the :py:obj:`OpenSSL.crypto` module.