Questions tagged [m2crypto]

M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, HMACs, message digests, symmetric ciphers (including AES); SSL functionality to implement clients and servers; HTTPS extensions to Python's httplib, urllib, and xmlrpclib; unforgeable HMAC'ing AuthCookies for web session management; FTP/TLS client and server; S/MIME; ZServerSSL.

M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, HMACs, message digests, symmetric ciphers (including AES); SSL functionality to implement clients and servers; HTTPS extensions to Python's httplib, urllib, and xmlrpclib; unforgeable HMAC'ing AuthCookies for web session management; FTP/TLS client and server; S/MIME; ZServerSSL.

271 questions
5
votes
2 answers

Implement OpenSSL AES Encryption in Python

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…
PizzaPanther
  • 1,321
  • 2
  • 12
  • 18
5
votes
2 answers

Extract userCertificate from PKCS7 envelop in python

Ok, I am trying to verify data from PKCS7 envelop using Python. I have the working code in Java: http://nyal.developpez.com/tutoriel/java/bouncycastle/#L4.2 What I want is first get the certificate from the envelop. I am able to open it with that…
Natim
  • 17,274
  • 23
  • 92
  • 150
5
votes
2 answers

How can I load a password-protected private key from a .pem file with M2Crypto?

I have a password-protected private key in a .pem file; I want to use it to sign requests to a remote server. I'm able to load the key and enter the passphrase after being prompted for it: python >>> import M2Crypto >>> pk =…
Tobias
  • 2,481
  • 3
  • 26
  • 38
4
votes
1 answer

Extract signing certs from a PKCS7 SignedData structure with m2crypto

I am trying to use M2Crypto to extract the signing certificates from a Windows PE file. According to the MS specification the data is stored in a PKCS#7 SignedData structure (stored in ASN.1 format, not the base64). I can't seem to get the binary…
tjac
  • 41
  • 2
4
votes
2 answers

easy_install M2Crypto failing on Windows platform

I am attempting to install M2Crypto on a Windows XP platform. I have Python, easy_install and SWIG installed, but when I attempt to easy_install M2Crypto I get the following: SWIG\_m2crypto.i(31) : Error: Unable to find…
Steve Criddle
  • 163
  • 2
  • 7
4
votes
1 answer

verify data signature generated with openssl, using crypto++

I have a server, running under python, signing a message sha256 digest using m2crypto I use a public and private RSA key generated by openssl CLI. On the server side everythgin is OK Python code : privateKey = M2Crypto.RSA.load_key(sys.argv[2]) …
4
votes
1 answer

Adding server certificate validation to httplib.HTTPSConnection

I've found that httplib.HTTPSConnection doesn't perform an automatic server certificate check. As far as I've understood the problem, I need to add that functionality manually, e.g. by subclassing this class as described here. As I'm using…
Johannes Charra
  • 29,455
  • 6
  • 42
  • 51
4
votes
2 answers

Python x509 get_serial_number() return incorrect value

I'm trying to get the serial number of a x509 with M2cryto the problem is that returns me different values ​​to openssl. from python >>> from M2Crypto import X509 >>> cer = X509.load_cert(cerPath, X509.FORMAT_DER) >>>…
4
votes
1 answer

How to extract RSA public exponent using python M2Crypto

I have the following piece of code that extract a host leaf certificate and the certificate RSA public key: c = ssock.getpeercert(True) x509 = M2Crypto.X509.load_cert_der_string(c) publickey=x509.get_pubkey() m=publickey.get_modulus() I tried to…
user2192774
  • 3,807
  • 17
  • 47
  • 62
4
votes
0 answers

Sign a soap Message through Python

I am struggling to Sign a XML soap message with a private key . I have done it in Java in the past , but having a very hard time in doing it through Python. I have kept a template XML in home directory , with values filled up for…
Ishu Gupta
  • 1,071
  • 1
  • 19
  • 43
4
votes
1 answer

Unable to install M2Crypto package

I am using Win7 64 bit machine with Python 2.7 installed. I have installed swigwin 3.0.5. When I do "pip install M2Crypto" I got the following errors: SWIG\_m2crypto.i(30) : Error: Unable to find 'openssl\opensslv.h' SWIG\_m2crypto.i(33) : Error:…
user3565150
  • 884
  • 5
  • 21
  • 49
4
votes
2 answers

error in importing M2Crypto Mac OS X

when I try to import M2Crypto in python, I get following error: I'm using Mac OS X, python 2.7 ImportError: dlopen(/Users/armita/.python-eggs/M2Crypto-0.22.3-py2.7-macosx-10.9-intel.egg-tmp/M2Crypto/__m2crypto.so, 2): Symbol not found: _X509_free …
Armita
  • 345
  • 1
  • 12
4
votes
2 answers

Validating SAML signature in python

I need to implement authentication in python from a 3rd party by using SAML2. I have looked into pysaml2 and found that to be quite confusing, and decided to give M2Crypto a chance after I found this question by Ennael. The SAML token I receive can…
Sindri Guðmundsson
  • 1,253
  • 10
  • 24
4
votes
2 answers

M2Crypto Error Installing on Windows

I'm trying to install the M2Crypto on Python26 in Windows, but I am getting the below error. error: command 'swig.exe' failed: No such file or directory This error occurs both using the "Easy Install" or "PIP Install" command. Follows the…
Eduardo
  • 1,698
  • 4
  • 29
  • 48
4
votes
1 answer

How to recreate the following signing cmd-line OpenSSL call using M2Crypto in Python?

This works perfectly in command-line, I would like to do the same using M2Crypto in Python code. openssl smime -binary -sign -signer certificate.pem -inkey key.pem \ -in some_file.txt -out signed_file -outform DER \ …
Elvin R.
  • 852
  • 1
  • 10
  • 20
1 2
3
18 19