Exception on request.shutdown with SimpleSecureHTTPServer

Bug #821984 reported by Rémy Roy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyopenssl (Ubuntu)
New
Undecided
Unassigned

Bug Description

Hello, I'm getting the follow exception while trying to run the SimpleSecureHTTPServer example from http://code.activestate.com/recipes/442473/ and hitting the server once.

Exception happened during processing of request from ('127.0.0.1', 36615)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 639, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 343, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 313, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/lib/python2.7/socket.py", line 476, in readline
    data = self._sock.recv(self._rbufsize)
Error: [('SSL routines', 'SSL3_READ_BYTES', 'tlsv1 alert unknown ca'), ('SSL routines', 'SSL23_READ', 'ssl handshake failure')]
----------------------------------------
Traceback (most recent call last):
  File "SimpleSecureHTTPServer.py", line 48, in <module>
    test()
  File "SimpleSecureHTTPServer.py", line 44, in test
    httpd.serve_forever()
  File "/usr/lib/python2.7/SocketServer.py", line 227, in serve_forever
    self._handle_request_noblock()
  File "/usr/lib/python2.7/SocketServer.py", line 287, in _handle_request_noblock
    self.shutdown_request(request)
  File "/usr/lib/python2.7/SocketServer.py", line 459, in shutdown_request
    request.shutdown(socket.SHUT_WR)
TypeError: shutdown() takes exactly 0 arguments (1 given)

Here are my system information:

Ubuntu version:
Description: Ubuntu 11.04
Release: 11.04

openssl:
  Installed: 0.9.8o-5ubuntu1
  Candidate: 0.9.8o-5ubuntu1
  Version table:
 *** 0.9.8o-5ubuntu1 0
        500 http://ca.archive.ubuntu.com/ubuntu/ natty/main amd64 Packages
        100 /var/lib/dpkg/status

python-openssl:
  Installed: 0.10-1ubuntu3
  Candidate: 0.10-1ubuntu3
  Version table:
 *** 0.10-1ubuntu3 0
        500 http://ca.archive.ubuntu.com/ubuntu/ natty/main amd64 Packages
        100 /var/lib/dpkg/status

python:
  Installed: 2.7.1-0ubuntu5
  Candidate: 2.7.1-0ubuntu5
  Version table:
 *** 2.7.1-0ubuntu5 0
        500 http://ca.archive.ubuntu.com/ubuntu/ natty/main amd64 Packages
        100 /var/lib/dpkg/status

python-dev:
  Installed: 2.7.1-0ubuntu5
  Candidate: 2.7.1-0ubuntu5
  Version table:
 *** 2.7.1-0ubuntu5 0
        500 http://ca.archive.ubuntu.com/ubuntu/ natty/main amd64 Packages
        100 /var/lib/dpkg/status

I've also tried it with using pyOpenSSL 0.12 with "pip install pyOpenSSL==0.12" in a virtualenv and I got the same error. I believe the package I currently have are the latest stable ones for natty.

This is most likely related to https://bugs.launchpad.net/pyopenssl/+bug/686804 .

I expected not to have this exception when I hit this secure HTTP server with a browser.

Revision history for this message
Rémy Roy (remyroy) wrote :

After some search, this is most likely a duplicate of https://bugs.launchpad.net/ubuntu/+source/pyopenssl/+bug/758037 . 758037 mentions that a fix has been applied in 0.10-1ubuntu3 but I still get the exception in 0.10-1ubuntu3 or even compiling from the source of 0.12 on pypi.

Any help would be appreciated. Thanks.

Revision history for this message
C.J. Steele (cjsteele) wrote :

I have a script I'm working on that creates a secure RCP over HTTP server and I've been confounded by an exception being thrown deep in the socket.py module -- through trouble-shooting I have discovered that this is due to an issue between python 2.6 and 2.7. Running stock 11.04, up to date.

Traceback (most recent call last):
  File "peerdisk-client.py", line 22, in <module>
    print broker.call('Sample2_main')
  File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1575, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1294, in single_request
    response = h.getresponse(buffering=True)
  File "/usr/lib/python2.7/httplib.py", line 1027, in getresponse
    response.begin()
  File "/usr/lib/python2.7/httplib.py", line 407, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.7/httplib.py", line 365, in _read_status
    line = self.fp.readline()
  File "/usr/lib/python2.7/socket.py", line 447, in readline
    data = self._sock.recv(self._rbufsize)
socket.error: [Errno 104] Connection reset by peer

Like I said, when I run it under python 2.6 I don't have any issues.

Revision history for this message
Rémy Roy (remyroy) wrote :

This is a duplicate of https://bugs.launchpad.net/pyopenssl/+bug/900792 and can be closed.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.