m2crypto

How do I install M2Crypto on Ubuntu?

I'm trying to build and install M2Crypto on Ubuntu 10.04 LTS. I downloaded and untarred M2Crypto-0.20.2.tar, and from the M2Crypto-0.20.2 directory I tried python setup.py build. I got an error because I don't have swig. So I ran sudo apt-get install swig. Then I tried python setup.py build again and got: /usr/lib/python2.6/distutil...

wrong behaviour of m2crypto compared to openssl

hello everybody, I have to consolidate and possibly rewrite a bunch of bash scripts that verify that incoming smime messages are valid (i.e. encrypted with company's private key and signed a certain set of public keys) This bunch of bash is going to be replaced by a small application, written possibly in Python with the help of M2C...

In Python M2Crypto I cannot set the socket timeout over 30 seconds

I have tried from M2Crypto import SSL handle = url_opener.open(theurl, urllib.urlencode(data), SSL.timeout(120)) also c = SSL.Connection(ctx) c.set_socket_read_timeout(SSL.timeout(120)) also SSL.Connection.set_socket_read_timeout(c, SSL.timeout(120)) I can set the timeout less than 30 seconds but not more than 30 seconds. ...

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 Python2.4.5 and an upgrade is not possible under the given circumstances, I cannot use the workaro...

M2Crypto: verifying DSA signatures

I'm having trouble verifying DSA signatures using Python/M2Crypto. The signatures are generated in Java, using standard java.security.Signature class, with Sun's crypto provider and SHA1withDSA algorithm designation. Here's some shell output: >>> pk <M2Crypto.DSA.DSA_pub instance at 0x20b6a28> >>> sig = '302c02141c4bbb218215ebfec572880...

How to 3DES encrypt in Python using the M2Crypto wrapper?

I have a working test of a hardware device that uses RSA encryption, in Python using M2Crypto. Now I need to test a similar device that uses 3DES encryption. But I can't figure out how to use M2Crypto to do triple DES encryption. I know it should be possible from this chart. But unfortunately the documentation of M2Crypto I've found ...

How can I properly sign x.509 certificates using a CA certificate in m2crypto?

I'm working on an automated CA for internal infrastructure that runs on Twisted Web and M2Crypto. The CA has its key. Other machines can send GET requests with the CSR as the body. Assuming things validate, the Helios server should respond in the body with the corresponding certificate. The complete source and test files for the applica...

Generating SHA-256 hash in Python 2.4 using M2Crypto

Is it possible to generate a SHA-256 hash using M2Crypto? Python 2.4's SHA module doesn't support 256, so I started using PyCrypto, only to find out that PyCrypto doesn't support PKCS#5 (needed elsewhere in my project.) I switched to M2Crypto as a result and now I would like to replace my PyCrypto SHA-256 call with an M2Crypto equivale...

Pythons M2Crypto raises exception in ssl_ctx_load_verify_locations when loading certificates

M2Crypto raises a TypeError when loading SSL CA certificates. I'm getting the path of an SSL certificate from an instance of a Django model. My code worked perfectly because I was pulling the path of the certificate from a Django model My code: from M2Crypto import SSL from django.db import models class MyModel(models.Model): ...

m2crypto: python 2.7 compatibility and which version of OpenSSL to use?

We've been using M2crypto with Python 2.6 for Windows (32-bit) for some time with great success. We used one of the user contributed setups to install M2crypto in our development environments. We would like to move to Python 2.7, but noticed there are no pre-built Python 2.7 setups for m2crypto. Questions: Is M2crypto 0.20.2 compatibl...

AES encryption library compatible with Python 2.7 for Windows

Any recommendations on an AES encryption library that's compatible with Python 2.7 for Windows? In the past we've used m2crypto with Python 2.6, but there's no version of m2crypto for Python 2.7 and our attempts to build a version from source have failed. Thank you, Malcolm ...

How to upload a file on FTPS server using m2crypto

I am trying to use ftps to upload file to our FTP server. Login is trivial and works: from M2Crypto import ftpslib ftp = ftpslib.FTP_TLS() ftp.connect(host) ftp.login(username, password) as well as descending into directory for dir in directory: ftp.cwd(dir) However, when trying to retrieve directory content: if directory_name...