Created on 2017-09-01 14:39 by vstinner, last changed 2017-09-13 00:54 by vstinner. This issue is now closed.
It would be nice to not log such traceback: haypo@selma$ ./python -m test test_ssl -m test.test_ssl.ThreadedTests.test_echo Run tests sequentially 0:00:00 load avg: 0.69 [1/1] test_ssl Exception in thread Thread-16: Traceback (most recent call last): File "/home/haypo/prog/python/master/Lib/threading.py", line 917, in _bootstrap_inner self.run() File "/home/haypo/prog/python/master/Lib/test/test_ssl.py", line 1936, in run if not self.wrap_conn(): File "/home/haypo/prog/python/master/Lib/test/test_ssl.py", line 1881, in wrap_conn self.sock, server_side=True) File "/home/haypo/prog/python/master/Lib/ssl.py", line 401, in wrap_socket _context=self, _session=session) File "/home/haypo/prog/python/master/Lib/ssl.py", line 808, in __init__ self.do_handshake() File "/home/haypo/prog/python/master/Lib/ssl.py", line 1061, in do_handshake self._sslobj.do_handshake() File "/home/haypo/prog/python/master/Lib/ssl.py", line 683, in do_handshake self._sslobj.do_handshake() OSError: [Errno 0] Error 1 test OK. Total duration: 205 ms Tests result: SUCCESS
Python 2.7 doesn't seem to be affected.
I don't get such traceback here (Ubuntu 16.04, OpenSSL 1.0.2g).
I'm running Fedora 26: haypo@selma$ ./python -m test.pythoninfo|grep -E 'ssl|platform' platform.architecture: 32bit ELF platform.platform: Linux-4.12.5-300.fc26.x86_64-x86_64-with-fedora-26-Twenty_Six platform.python_implementation: CPython ssl.HAS_SNI: True ssl.OPENSSL_VERSION: OpenSSL 1.1.0f-fips 25 May 2017 ssl.OPENSSL_VERSION_INFO: (1, 1, 0, 6, 15) ssl.OP_ALL: -0x7fffffac ssl.OP_NO_TLSv1_1: 0x10000000 sys.platform: linux
Not sure if you just want to hide the presence of the exception and traceback. But regarding the exception itself (OSError with errno 0), this is not ideal. From memory, you tend to get this when the connection is shut down insecurely at the TCP level. A better exception would be SSLEOFError. Similar report in Issue 31122 (same wrap_socket → do_handshake chain). Probably also relevant: Issue 10808.
The error occurs in the test case that uses a PROTOCOL_TLS_SERVER context for both client and server context. In that case, OpenSSL wrap_socket() fails internally and OpenSSL raises an OSError with errno 0. Simple fix: catch OSError in the client thread and fail the test appropriately.
New changeset 305e56c27afce605e5d2f71903a966cf0bb95038 by Christian Heimes in branch 'master': bpo-31320: No traceback to sys.stderr in test_ssl (#3360) https://github.com/python/cpython/commit/305e56c27afce605e5d2f71903a966cf0bb95038
New changeset c506403faf8dbfc8baf4212e8e2aedb7268acb5e by Mariatta (Miss Islington (bot)) in branch '3.6': [3.6] bpo-31320: No traceback to sys.stderr in test_ssl (GH-3360) (GH-3369) https://github.com/python/cpython/commit/c506403faf8dbfc8baf4212e8e2aedb7268acb5e
Thanks for the fix Christian.
stage: resolved