Reputation: 41
I am trying to verify a signature using pyOpenSSL with Python 3.4.2. Here is my code.
from OpenSSL import crypto
some_byte_string = b'This is a byte string.'
crt = crypto.load_certificate(crypto.FILETYPE_PEM, pem)
# self.signature is a base64 encoded string
crypto.verify(crt, self.signature, some_byte_string, 'sha1')
That produces the following exception:
verify_result = _lib.EVP_VerifyFinal(md_ctx, signature, len(signature), pkey)
TypeError: initializer for ctype 'unsigned char *' must be a bytes or list or tuple, not str
I have also tried using a regular string for 'some_byte_string' but I get the following exception when I try that:
_lib.EVP_VerifyUpdate(md_ctx, data, len(data))
TypeError: initializer for ctype 'void *' must be a cdata pointer, not str
I saw a previous SO question that referenced the unittest for pyOpenSSL verify and this appears to be what I am doing though obviously something is wrong.
Edit: Forgot to mention the version of pyOpenSSL I am using is pyOpenSSL-0.14-py3.4.
Upvotes: 3
Views: 1773
Reputation: 41
Apparently it's a bug with 0.14 and will be fixed in 0.15.
https://github.com/pyca/pyopenssl/issues/15
Upvotes: 1