Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development server fails on first SSL request #249

Closed
abramclark opened this issue Jan 16, 2013 · 2 comments
Closed

Development server fails on first SSL request #249

abramclark opened this issue Jan 16, 2013 · 2 comments

Comments

@abramclark
Copy link

When using the dev server with SSL, an exception is thrown and the server shuts down during the first request. When a valid and recognized SSL cert is provided, the browser just shows a connection rejected message. If an unrecognized SSL cert is supplied, the browser shows the standard SSL warning. This means SSL must be working partially.

I'm using Ubuntu 12.04, Werkzeug 0.8.3, and pyOpenSSL 0.13.

Here's the stack trace that the server produces:

Unhandled exception in thread started by <function inner at 0x47206e0>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 599, in inner
passthrough_errors, ssl_context).serve_forever()
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 358, in serve_forever
HTTPServer.serve_forever(self)
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)

@danse
Copy link

danse commented Feb 6, 2013

I had a similar problem when running with ssl_context='adhoc':

Unhandled exception in thread started by <function inner at 0x3152938>
Traceback (most recent call last):
  File "/home/pc013/repos/frontend/ENV/local/lib/python2.7/site-packages/werkzeug/serving.py", line 599, in inner
    passthrough_errors, ssl_context).serve_forever()
  File "/home/pc013/repos/frontend/ENV/local/lib/python2.7/site-packages/werkzeug/serving.py", line 358, in serve_forever
    HTTPServer.serve_forever(self)
  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)

Looking at this python bug report I thought this could be a problem with the request, which should be a socket object.

Indeed, the socket is wrapped by a _SSLConnectionFix class in werkzeug serving.py for werkzeug 0.8.3, and that class requires to override also the shutdown method. A patch which worked for me was:

299a300,303
>     def shutdown(self, args=None):
>         return self._con.shutdown()
> 
> 

That is, you should add that method to _SSLConnectionFix

I also saw that the current serving.py on github already handles this correctly, but I was not able to use it for other errors.

So, if you have to use werkzeug 0.8.3, try this patch on serving.py

@untitaker
Copy link
Contributor

Using custom cert and key works for me, using "adhoc" as ssl_context works after applying #229.

@DasIch DasIch closed this as completed Jun 20, 2013
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants