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

OpenSSL fails to do handshake (or smth else?) after upgrading from Python 2.7 to Python 3.7 #132

Closed
1 of 3 tasks
matingara opened this issue Oct 12, 2018 · 11 comments
Closed
1 of 3 tasks
Labels
reproducer: missing This PR or issue lacks code, which reproduce the problem described or clearly understandable STR

Comments

@matingara
Copy link

matingara commented Oct 12, 2018

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository

Describe the bug. What is the current behavior?

Below is a REPL session using Python 2.7 and another REPL session using Python 3.7.
Can anyone please shed any light on this?
Thanks.

What is the motivation / use case for changing the behavior?

???

To Reproduce

Steps to reproduce the behavior:
PYTHON 3.7 REPL SESSION

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cherrypy
>>> server_config={
...       'server.ssl_module':'pyopenssl',
...       'server.ssl_certificate':'cert.pem',
...       'server.ssl_private_key':'key.pem'
... }
>>> cherrypy.config.update(server_config)
>>> cherrypy.server.socket_host = '127.0.0.1'
>>> cherrypy.server.socket_port = 443
>>> cherrypy.quickstart()
[12/Oct/2018:16:08:55] ENGINE Listening for SIGTERM.
[12/Oct/2018:16:08:55] ENGINE Listening for SIGHUP.
[12/Oct/2018:16:08:55] ENGINE Listening for SIGUSR1.
[12/Oct/2018:16:08:55] ENGINE Bus STARTING
CherryPy Checker:
The Application mounted at '' has an empty config.

[12/Oct/2018:16:08:55] ENGINE Started monitor thread 'Autoreloader'.
[12/Oct/2018:16:08:55] ENGINE Serving on https://127.0.0.1
[12/Oct/2018:16:08:55] ENGINE Bus STARTED
[12/Oct/2018:16:08:55] ENGINE SysCallError(-1, 'Unexpected EOF')
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cheroot/server.py", line 1219, in communicate
    req.parse_request()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cheroot/server.py", line 689, in parse_request
    success = self.read_request_line()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cheroot/server.py", line 728, in read_request_line
    request_line = self.rfile.readline()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cheroot/server.py", line 277, in readline
    data = self.rfile.readline(256)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_pyio.py", line 513, in readline
    b = self.read(nreadahead())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_pyio.py", line 492, in nreadahead
    readahead = self.peek(1)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_pyio.py", line 1076, in peek
    return self._peek_unlocked(size)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_pyio.py", line 1083, in _peek_unlocked
    current = self.raw.read(to_read)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1814, in recv_into
    self._raise_ssl_error(self._ssl, result)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1632, in _raise_ssl_error
    raise SysCallError(-1, "Unexpected EOF")
OpenSSL.SSL.SysCallError: (-1, 'Unexpected EOF')

Expected behavior

PYTHON 2.7 REPL SESSION

Python 2.7.10 (default, Oct  6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cherrypy
>>> server_config={
...       'server.ssl_module':'pyopenssl',
...       'server.ssl_certificate':'cert.pem',
...       'server.ssl_private_key':'key.pem'
... }
>>> cherrypy.config.update(server_config)
>>> cherrypy.server.socket_host = '127.0.0.1'
>>> cherrypy.server.socket_port = 443
>>> cherrypy.quickstart()
[12/Oct/2018:15:48:37] ENGINE Listening for SIGHUP.
[12/Oct/2018:15:48:37] ENGINE Listening for SIGTERM.
[12/Oct/2018:15:48:37] ENGINE Listening for SIGUSR1.
[12/Oct/2018:15:48:37] ENGINE Bus STARTING
CherryPy Checker:
The Application mounted at '' has an empty config.

[12/Oct/2018:15:48:37] ENGINE Started monitor thread 'Autoreloader'.
[12/Oct/2018:15:48:37] ENGINE Started monitor thread '_TimeoutMonitor'

Details

???

Environment

  • Cheroot version: X.X.X???
  • CherryPy version: X.X.X???
  • Python version: v3.7.0:1bf9cc5093
  • OS: macOS ???
  • Browser: ???

Additional context

???

@webknjaz webknjaz added the invalid This is irrelevant label Oct 12, 2018
@webknjaz

This comment has been minimized.

@webknjaz
Copy link
Member

Oh, you wrote details inside of HTML comments, which don't render visibly..

@webknjaz webknjaz reopened this Oct 12, 2018
@webknjaz webknjaz removed the invalid This is irrelevant label Oct 12, 2018
@webknjaz

This comment has been minimized.

@webknjaz webknjaz changed the title Cherrypy Webserver Not Working after Upgrading from Python 2.7 to Python 3.7 OpenSSL fails to do handshake (or smth else?) after upgrading from Python 2.7 to Python 3.7 Oct 12, 2018
@webknjaz
Copy link
Member

@matingara so ssl is not in a good shape now, but it'll probably work if you switch to builtin.
Other than that, you need to provide versions of everything and details of what you did for someone to be able to help you.
Logs you sent differ, which probably also means different versions of python dists. It's also not clear what are the pre-conditions for such behavior and whether or not you did HTTP call to trigger the traceback.

@webknjaz
Copy link
Member

@matingara so in your Python 3.7 log you're probably receiving an HTTP call instead of HTTPS, which is done by Checker.

Try setting 'checker.on': False to disable this behavior (it's disabled by default in non-dev envs).

@matingara
Copy link
Author

matingara commented Oct 15, 2018 via email

@matingara
Copy link
Author

matingara commented Oct 16, 2018 via email

@webknjaz
Copy link
Member

What are the new logs?

And by builtin I mean ssl module from Python stdlib:

cherrypy.server.ssl_module = 'builtin'

As for updating CherryPy, I suggest you update to v17.4.0 (last one supporting Python 2) under Python 2.7, check that there's no regressions and then move on to next versions.

@stale
Copy link

stale bot commented Dec 15, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale This thing has been ignored for too long label Dec 15, 2018
@webknjaz webknjaz added the reproducer: missing This PR or issue lacks code, which reproduce the problem described or clearly understandable STR label Dec 17, 2018
@stale stale bot removed the stale This thing has been ignored for too long label Dec 17, 2018
@webknjaz
Copy link
Member

@matingara is this still reproducible with current Cheroot master?

@webknjaz
Copy link
Member

It looks like it's solved. Feel free to reopen with new details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reproducer: missing This PR or issue lacks code, which reproduce the problem described or clearly understandable STR
Projects
None yet
Development

No branches or pull requests

2 participants