pyopenssl

Django runserver_plus pyOpenSSL not installed error, although it is

Django runserver_plus pyOpenSSL not installed error, although it is Question: Linux Mint 19.3, Python 3.8 virtual environment. So I try to run runserver_plus using ssl: python manage.py runserver_plus –cert-file cert.crt Then I get following error: CommandError: Python OpenSSL Library is required to use runserver_plus with ssl support. Install via pip (pip install pyOpenSSL). But the …

Total answers: 2

How to extract the signature from a p7s file?

How to extract the signature from a p7s file? Question: I need the Python code to extract from the p7s file the signature resulting from digitally signing a document, in both situations where the payload is inside of, and external to, the p7s file. I have tried several crypto packages (PyOpenSSL, PyCripto, Cryptography, ASN1Crypto, and …

Total answers: 2

How do I read(open) an ASN.1 file in python

How do I read(open) an ASN.1 file in python Question: I want to get a certificates serial number using python: der = open(‘/Users/me/MyApp/Payload/codesign0’).read()“` cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, der cert.get_serial_number() Unfortunately it fails in the first line: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x82 in position 1: invalid start byte How do I read an ASN.1 file …

Total answers: 3

Python AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

Python AttributeError: 'module' object has no attribute 'SSL_ST_INIT' Question: A Python script of mine is failing with: Traceback (most recent call last): File “./inspect_sheet.py”, line 21, in <module> main() File “./inspect_sheet.py”, line 12, in main workbook_name=workbook_name, File “./google_sheets.py”, line 56, in __init__ self.login() File “./google_sheets.py”, line 46, in login self.client = gspread.authorize(credentials) File “/usr/local/lib/python2.7/site-packages/gspread/client.py”, line …

Total answers: 23

AttributeError: 'Context' object has no attribute 'wrap_socket'

AttributeError: 'Context' object has no attribute 'wrap_socket' Question: I am trying to set up a Flask server that uses an OpenSSL context. However, since I moved the script on a different server, it keeps throwing the following error, no matter if I am using Python 2.7 or 3.4 and no matter which SSL method I …

Total answers: 1

Web app hangs for several hours in ssl.py at self._sslobj.do_handshake()

Web app hangs for several hours in ssl.py at self._sslobj.do_handshake() Question: I am using Python 2.7.5. I have a web app which queries an API every few minutes and has been working successfully for the last day or so. However, after leaving it sitting for a few hours, I came back to find my program …

Total answers: 4

get public key from private key with python OpenSSL

get public key from private key with python OpenSSL Question: Well, I generate a private key with pyOpenSSL as follows: from OpenSSL import crypto k = crypto.PKey() k.generate_key(crypto.TYPE_RSA, 2048) print crypto.dump_privatekey(crypto.FILETYPE_PEM, k) How do I get the public key string from it? I’ve still not found what method of this library does it. Thanks Asked …

Total answers: 2

How to install OpenSSL for Python

How to install OpenSSL for Python Question: I need to install OpenSSL on my python2.7. I tried $ pip install pyopenssl And I got the following /usr/local/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: ‘zip_safe’ warnings.warn(msg) running build running build_py running build_ext building ‘OpenSSL.crypto’ extension gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.7 …

Total answers: 1

extracting public key from certificate and encrypting data

extracting public key from certificate and encrypting data Question: This is for a homework assignment! I get the server’s certificate using get_peer_certificate() and the calling dump_certificate to dump the certificate in a variable. The format is PEM and looks right to me. —–BEGIN CERTIFICATE—– GIBBERISH……………. …………………. …………………… —–END CERTIFICATE—– How do I extract the server’s …

Total answers: 4

HTTPS connection Python

HTTPS connection Python Question: I am trying to verify the that target exposes a https web service. I have code to connect via HTTP but I am not sure how to connect via HTTPS. I have read you use SSL but I have also read that it did not support certificate errors. The code I …

Total answers: 8