I am using httplib2 for opening up an ssl connection. Following is the code.
import httplib2
if __name__=='__main__':
conn = httplib2.Http(disable_ssl_certificate_validation=True)
conn.add_certificate('serverkey.pem', 'servercert.pem', '')
resp, content = conn.request(uri = 'https://xxx.xxx.xxx.xxx:xxxx/Konfigurator
/REST/login?userName=xxx&pass=xxx', method = 'POST')
print resp
this is the error I am getting.
Traceback (most recent call last):
File "C:\eclipse-workspace\REST\src\examples.py", line 7, in <module>
resp, content = conn.request(uri = 'https://xxx.xxx.xxx.xxx:xxx/Konfigurator/REST/login?userName=xxx&pass=xxx', method = 'POST')
File "C:\Python27\lib\site-packages\httplib2-0.7.1-py2.7.egg\httplib2\__init__.py", line 1437, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "C:\Python27\lib\site-packages\httplib2-0.7.1-py2.7.egg\httplib2\__init__.py", line 1189, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "C:\Python27\lib\site-packages\httplib2-0.7.1-py2.7.egg\httplib2\__init__.py", line 1163, in _conn_request
conn.connect()
File "C:\Python27\lib\site-packages\httplib2-0.7.1-py2.7.egg\httplib2\__init__.py", line 925, in connect
raise socket.error, msg
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host
Is the code correct or am I missing something here?
I got it working. The problem was the server supported only TLSv1 and SSLv3 encryptions. The httplib2 module had defaulted to SSLv23 if no version was specified. This was resulting in the server responding with RST packets. Probably a bug in their code. Made the change in their init.py to include "ssl_version=3" (3 for TLS) in the wrap_socket function and it worked.