pyopenssl

Verify signature with pyopenssl

我是研究僧i 提交于 2019-12-05 00:39:44
问题 I believe that since this question, pyOpenSSL has started supporting the verification of signatures (as of pyOpenSSL 0.11. I am working on a project which was started by someone else using M2Crypto. M2Crypto is really painful to include on platforms such as Heroku as it requires the use of SWIG. Consequently I am trying to remove the dependency on M2Crypto and replace with pyOpenSSL which is easy to install via Pip, and doesn't require custom buildpacks and more which SWIG-related things do.

How do I create and sign certificates with Python's pyOpenSSL?

六眼飞鱼酱① 提交于 2019-12-04 13:45:55
问题 I would like to use python to create a CA certificate, and client certificates that I sign with it. I will be using these with OpenVPN. After several days of research, and trial and error, this is what I've come up with: #!/usr/bin/env python import os import sys import random from OpenSSL import crypto ########### # CA Cert # ########### ca_key = crypto.PKey() ca_key.generate_key(crypto.TYPE_RSA, 2048) ca_cert = crypto.X509() ca_cert.set_version(2) ca_cert.set_serial_number(random.randint

How to generate the PEM serialization for the public RSA/DSA key

你离开我真会死。 提交于 2019-12-04 05:32:58
Using PyCrypto I was able to generate the public and private PEM serialization for a RSA key, but in PyCrypto the DSA class has no exportKey() method. Trying PyOpenSSL I was able to generate the private PEM serialization for RSA and DSA keys, bu there is no crypto.dump_publickey method in PyOpenSSL. I am looking for suggestion of how to generate the PEM serialization for RSA and DSA keys. Many thanks! PS: meanwhile I have changed the PyOpenSSL code to also export an dump_privatekey method for crypto API. PyOpenSSL bug and patch can be found at: https://bugs.launchpad.net/pyopenssl/+bug/780089

pyOpenSSL's PKCS7 object provide very little information, how can I get the sha1 digest of the public key in the signature

末鹿安然 提交于 2019-12-04 05:29:14
问题 I would like to parse android apk's CERT.RSA in Python. I know it can be parsed with pyOpenSSL import OpenSSL cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, open('CERT.RSA', 'rb').read()) cert = OpenSSL.crypto.load_pkcs7_data(type, buffer) cert is of type 'OpenSSL.crypto.PKCS7'. BUT right now PKCS7 object is not complete, I cannot get attributes I need, is there any alternative way to parse that file? 回答1: Comments : I don't know if there's a way to convert it to another

PKCS #7 detached signature with Python and PyOpenSSL

好久不见. 提交于 2019-12-03 09:01:33
I need to get a detached PKCS #7 signature of some string in Python, using PyOpenSSL. I've got a key in .p12 file. So far, I'm trying to do so: from OpenSSL.crypto import load_pkcs12, sign pkcs12 = load_pkcs12(key_dat, key_pwd) algo = pkcs12.get_certificate().get_signature_algorithm() pkey = pkcs12.get_privatekey() sg = sign(pkey, manifest, algo) But it's not what required. I've searched net, but most examples are related to signing email chunks and use M2Crypto. Is there any way of doing it in bare PyOpenSSL? The PKCS#7 OpenSSL functions that you need for this do not seem to be exported by

How do I create and sign certificates with Python's pyOpenSSL?

社会主义新天地 提交于 2019-12-03 08:33:15
I would like to use python to create a CA certificate, and client certificates that I sign with it. I will be using these with OpenVPN. After several days of research, and trial and error, this is what I've come up with: #!/usr/bin/env python import os import sys import random from OpenSSL import crypto ########### # CA Cert # ########### ca_key = crypto.PKey() ca_key.generate_key(crypto.TYPE_RSA, 2048) ca_cert = crypto.X509() ca_cert.set_version(2) ca_cert.set_serial_number(random.randint(50000000,100000000)) ca_subj = ca_cert.get_subject() ca_subj.commonName = "My CA" ca_cert.add_extensions(

Patch pyopenssl for sslv3 issue

我怕爱的太早我们不能终老 提交于 2019-12-03 06:13:41
问题 I got a problem on a Debian 8 system with python 2.7.9-2 amd64: marius@pydev:/usr/lib/python2.7/dist-packages/urllib3/contrib$ pip search doo Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in

Patch pyopenssl for sslv3 issue

限于喜欢 提交于 2019-12-02 18:42:29
I got a problem on a Debian 8 system with python 2.7.9-2 amd64: marius@pydev:/usr/lib/python2.7/dist-packages/urllib3/contrib$ pip search doo Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190,

Why is context.set_tmp_ecdh() not defined in pyOpenSSL?

谁都会走 提交于 2019-12-02 15:37:40
问题 I'm trying to implement the answer found at Python Paste SSL server with TLSv1.2 and Forward Secrecy. How do I use context.set_tmp_ecdh()? That method is not defined on either my Linux or Windows machines. It is in the pyOpenSSL docs, and various examples I've seen. I'm using Python 2.6.6 (or 2.7) and pyOpenSSL v 0.13 (specifically CentOS package pyOpenSSL-0.13.1-2.el6.x86_64.rpm). Is there a specific version or additional dependency, etc. that I'm missing? 回答1: Support for ecdh was added in

How to get current cipher in pyOpenSSL for DTLS

半腔热情 提交于 2019-12-02 08:04:29
问题 I need to get a negotiated cipher for DTLS protocol in pyOpenSSL. I was successful in doing that for TCP sockets, but when it comes to datagrams, it's not that obvious. Please provide an example either in C or Python. This is what I've tried so far: import socket from OpenSSL import SSL from OpenSSL._util import ( ffi as _ffi, lib as _lib) DTLSv1_METHOD = 7 SSL.Context._methods[DTLSv1_METHOD]=getattr(_lib, "DTLSv1_client_method") ctx = SSL.Context(DTLSv1_METHOD) ctx.set_cipher_list('AES128