summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2016-06-03 15:21:44 -0700
committerHynek Schlawack <hs@ox.cx>2016-06-03 15:21:44 -0700
commit32fc4e6460842c9b0983008f105b04f77e4b5633 (patch)
tree9ba02c52ca774ab78508d770637cc420b48ade56
parent8edeb3a214c61b2f5c2abbd8bbb0a51709a1126b (diff)
downloadpyopenssl-32fc4e6460842c9b0983008f105b04f77e4b5633.tar.gz
fix a small bug with load_publickey (#481)
* fix a small bug with load_publickey * update docstring, rename test method * make hynek happy
-rw-r--r--src/OpenSSL/crypto.py1
-rw-r--r--tests/test_crypto.py14
2 files changed, 15 insertions, 0 deletions
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 @@ def load_publickey(type, buffer):
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 @@ def _runopenssl(pem, *args):
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.