m2crypto

Sign CSR from client using CA root certificate in python

家住魔仙堡 提交于 2019-11-29 14:17:24
问题 I am new to python and still learning it so my question can be little naive. Please bear with it ;) The problem is client will be sending CSR and I want to sign it with my CA root certificate and return the signed certificate back to client. I have been using this command to do it using command line openssl x509 -req -in device.csr -CA root.pem -CAkey root.key -CAcreateserial -out device.crt -days 500 same thing I want achieve using python. I have come across python library for openssl

Implement OpenSSL AES Encryption in Python

霸气de小男生 提交于 2019-11-29 02:45:06
I'm trying to implement the following in Python: openssl enc -e -aes-256-cbc -base64 -k "Secret Passphrase" -in plaintext.txt -out ciphertext.txt openssl enc -d -aes-256-cbc -base64 -k "Secret Passphrase" -in ciphertext.txt -out verification.txt I've tried several different modules, PyCrypto, M2Crypto, etc but can't seem to get the correct combination of changing the password to the right size key and encoding everything correctly. I've found https://github.com/nvie/SimpleAES but that basically runs OpenSSL on the command line, which I'd rather avoid. SquareRootOfTwentyThree Base 64 encoding

Trouble installing m2crypto with pip on OS X / macOS

天涯浪子 提交于 2019-11-28 14:07:50
问题 pip install m2crypto Generates the following output: building 'M2Crypto.__m2crypto' extension swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c swig -python -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i SWIG/_m2crypto.i:30: Error: Unable to find 'openssl/opensslv.h' SWIG/_m2crypto.i:33: Error: Unable to find 'openssl/safestack.h' SWIG/_evp.i:12: Error: Unable to

How to Install M2crypto on Windows

拟墨画扇 提交于 2019-11-28 12:04:28
After installing OpenSSL , downloading the pre-built Swig executable , and ensuring the openssl libraries are located in the default c:\pkg , pip install m2crypto results in: ... C:\Program Files (x86)\gfortran\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Pyth on27\include -IC:\Python27\PC -Ic:\pkg\include -Ic:\users\evbo\appdata\local\tem p\pip_build_evbo\m2crypto\SWIG -c SWIG/_m2crypto_wrap.c -o build\temp.win32-2.7\ Release\swig\_m2crypto_wrap.o -DTHREADING gcc: error: unrecognized command line option '-mno-cygwin' error: command 'gcc' failed with exit status 1 It seems the binary installer

Install m2crypto on a virtualenv without system packages

一个人想着一个人 提交于 2019-11-27 12:20:08
问题 I have created a virtual environment without the system packages with python's virtualenv in Ubuntu and installed m2crypto, but when I execute a shell and I try to import M2Crypto i get the following error: ImportError: /home/imediava/.virtualenvs/myenv/local/lib/python2.7/site- packages/M2Crypto/__m2crypto.so: undefined symbol: SSLv2_method From outside the environment I run into the same problem unless from ubuntu I install python-m2crypto with apt-get. I know that I could create the

How can I retrieve the TLS/SSL peer certificate of a remote host using python?

送分小仙女□ 提交于 2019-11-27 11:07:52
I need to scan through a list of IPs and retrieve the common name from the certificate on that IP (for every IP that allows port 443 connections). I have been able to successfully do this using the sockets and ssl modules. It works for all IPs with valid, signed certificates but it isn't working for self-signed certificates. If I use this method, it requires a valid cert that is verified by my CA-bundle: from socket import socket import ssl s = socket() c = ssl.wrap_socket(s,cert_reqs=ssl.CERT_REQUIRED, ca_certs='ca-bundle.crt') c.connect(('127.0.0.1', 443)) print c.getpeercert() If I remove

How do I use m2crypto to validate a X509 certificate chain in a non-SSL setting

白昼怎懂夜的黑 提交于 2019-11-27 07:00:50
问题 I'm trying to figure out how to, using m2crypto, validate the chain of trust from a public key version of a X509 certificate back to one of a set of known root CA's when the chain may be arbitrarily long. The SSL.Context module looks promising except that I'm not doing this in the context of a SSL connection and I can't see how the information passed to load_verify_locations is used. Essentially, I'm looking for the interface that's equivalent to: openssl verify pub_key_x509_cert Is there

How to generate SSH key pairs with Python

假装没事ソ 提交于 2019-11-27 05:19:09
问题 I'm attempting to write a script to generate SSH Identity key pairs for me. from M2Crypto import RSA key = RSA.gen_key(1024, 65337) key.save_key("/tmp/my.key", cipher=None) The file /tmp/my.key looks great now. By running ssh-keygen -y -f /tmp/my.key > /tmp/my.key.pub I can extract the public key. My question is how can I extract the public key from python? Using key.save_pub_key("/tmp/my.key.pub") saves something like: -----BEGIN PUBLIC KEY-----