3

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.

1 Answer 1

1

Apparently it's a bug with 0.14 and will be fixed in 0.15.

https://github.com/pyca/pyopenssl/issues/15

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.