socket.setdefaulttimeout interacting with M2Crypto connection

Posted by Becky on Stack Overflow See other posts from Stack Overflow or by Becky
Published on 2010-03-11T19:20:09Z Indexed on 2010/03/11 19:24 UTC
Read the original article Hit count: 362

Filed under:

Hello -

I'm making a secure SSL connection to a server using python and M2Crypto. See code below.

from M2Crypto import SSL, m2,x509
from M2Crypto.m2xmlrpclib import Server, SSL_Tranport
ctx = SSL.Context()
m2.ssl_ctx_use_pkey_privkey(ctx.ctx,myKey.pkey)
m2.ssl_ctx_use_x509(ctx.ctx,myCert.x509)
server = Server(serverUrl, SSL_Transport(ctx))
server.ping()

The above works fine. If I try to change the default socket timeout by adding the following two lines at the beginning of the code, I get a protocol error.

import socket
socket.setdefaulttimeout(40)

This is the error I receive:

File "/usr/local/lib/python2.4/xmlrpclib.py", line 1096, in call return self._send(self._name, args) File "/usr/local/lib/python2.4/xmlrpclib.py", line 1383, in _request verbose=self._verbose File "/usr/local/lib/python2.4/site-packages/M2Crypto/m2xmlrpclib.py", line 68, in request headers xmlrpclib.ProtocolError:

Why is the default socket timeout causing problems?

© Stack Overflow or respective owner

Related posts about m2crypto