[PYTHON-CRYPTO] m2crypto blocking all other threads

Heikki Toivonen heikki at OSAFOUNDATION.ORG
Thu Sep 22 06:51:43 CEST 2005

Rune Froysa wrote:
> I'm using m2crypto for a SSL-based xmlrpc service.  This service is
> frequently DOSed by what appears to be a bug in m2crypto: it blocks

It seems like this is user error. In a multithreaded application you
need to initialize M2Crypto for threading. With those changes your
sample works for me. See below:

> #!/usr/bin/env python
> import sys, time, threading

from M2Crypto import threading as m2threading

> demo_dir='/tmp/m2crypto-0.15/demo/ssl'
> sys.path.insert(0, demo_dir)
> from https_srv import *
> def my_wt():
>     while True:
>         time.sleep(0.5)
>         print "test"
> if __name__ == '__main__':


>     threading.Thread(target=my_wt).start()
>     ctx = init_context('sslv23', '%s/server.pem' % demo_dir, '%s/ca.pem' % demo_dir, 
>                        SSL.verify_none)
>     httpsd = HTTPS_Server(('', 9443), HTTP_Handler, ctx)
>     httpsd.serve_forever()


> BTW: under 0.15, the https_srv.py complains from line 126 -> SSL/Context.py: 118:
> TypeError: ssl_ctx_load_verify_locations() argument 3 must be string, not None

This does not happen for me.

Please note that I did find a bug in Connection.py regarding handling of
post connection checks and just fixed them.

  Heikki Toivonen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-crypto/attachments/20050921/f74b25c8/attachment.pgp>

More information about the python-crypto mailing list