socket.setdefaulttimeout interacting with M2Crypto connection
- by Becky
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?