Skip to content

bpo-37322: Fix test_ssl.test_pha_required_nocert() ResourceWarning #14662

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

Merged
merged 1 commit into from
Jul 9, 2019
Merged

bpo-37322: Fix test_ssl.test_pha_required_nocert() ResourceWarning #14662

merged 1 commit into from
Jul 9, 2019

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jul 9, 2019

Close the TLS connection in test_pha_required_nocert() of test_ssl to
fix a ResourceWarning.

https://bugs.python.org/issue37322

Close the TLS connection in test_pha_required_nocert() of test_ssl to
fix a ResourceWarning.
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@vstinner vstinner deleted the test_pha_required_nocert_reswarn branch July 9, 2019 10:36
@bedevere-bot
Copy link

GH-14665 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 9, 2019
…ythonGH-14662)

Close the TLS connection in test_pha_required_nocert() of test_ssl to
fix a ResourceWarning.
(cherry picked from commit cf9c41c)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Windows10 3.x has failed when building commit cf9c41c.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/3/builds/3121) and take a look at the build logs.
  4. Check if the failure is related to this commit (cf9c41c) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/3/builds/3121

Failed tests:

  • test_ssl

Failed subtests:

  • test_pha_required_nocert - test.test_ssl.TestPostHandshakeAuth

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

387 tests OK.

10 slowest tests:

  • test_mmap: 5 min 1 sec
  • test_tools: 2 min 46 sec
  • test_io: 2 min 38 sec
  • test_multiprocessing_spawn: 2 min 29 sec
  • test_tokenize: 1 min 58 sec
  • test_concurrent_futures: 1 min 42 sec
  • test_largefile: 1 min 37 sec
  • test_lib2to3: 1 min 20 sec
  • test_asyncio: 59 sec 854 ms
  • test_capi: 54 sec 656 ms

1 test failed:
test_ssl

31 tests skipped:
test_crypt test_curses test_dbm_gnu test_dbm_ndbm test_devpoll
test_epoll test_fcntl test_fork1 test_gdb test_grp test_ioctl
test_kqueue test_multiprocessing_fork
test_multiprocessing_forkserver test_nis test_openpty
test_ossaudiodev test_pipes test_poll test_posix test_pty test_pwd
test_readline test_resource test_spwd test_syslog
test_threadsignals test_wait3 test_wait4 test_xxtestfuzz
test_zipfile64

1 re-run test:
test_ssl

Total duration: 12 min 18 sec

Click to see traceback logs
Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
k


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
 server:  new connection from ('127.0.0.1', 56026)
 server: connection cipher is now ('TLS_AES_256_GCM_SHA384', 'TLSv1.3', 256)
 server: selected protocol is now None
 Connection reset by peer: ('127.0.0.1', 56026)
k


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
 server:  new connection from ('127.0.0.1', 56009)


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 OSError: [Errno 0] Error
 server:  new connection from ('127.0.0.1', 56939)


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:1108)
 server:  new connection from ('127.0.0.1', 56118)
 server: connection cipher is now ('TLS_AES_256_GCM_SHA384', 'TLSv1.3', 256)
 server: selected protocol is now None
 Connection reset by peer: ('127.0.0.1', 56118)
k


Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2299, in run
    msg = self.read()
  File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2276, in read
    return self.sslconn.read()
  File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1101, in read
    return self._sslobj.read(len)
ssl.SSLError: [SSL: PEER_DID_NOT_RETURN_A_CERTIFICATE] peer did not return a certificate (_ssl.c:2560)


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1108)
k


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:1108)
k


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLError: [SSL] called a function you should not call (_ssl.c:1108)
 server:  new connection from ('127.0.0.1', 56138)


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 OSError: [Errno 0] Error
 server:  new connection from ('127.0.0.1', 56140)


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
 server:  new connection from ('127.0.0.1', 56840)
 server: connection cipher is now ('TLS_AES_256_GCM_SHA384', 'TLSv1.3', 256)
 server: selected protocol is now None
 Connection reset by peer: ('127.0.0.1', 56840)
k


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
 server:  new connection from ('127.0.0.1', 56038)


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLError: [SSL: SSLV3_ALERT_BAD_CERTIFICATE] sslv3 alert bad certificate (_ssl.c:1108)
k


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:1108)
k


Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\threading.py", line 938, in _bootstrap_inner
    self.run()
  File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2386, in run
    raise ssl.SSLError('tlsv13 alert certificate required')
ssl.SSLError: ('tlsv13 alert certificate required',)
ERROR


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLError: [SSL] called a function you should not call (_ssl.c:1108)
k


Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 4344, in test_pha_required_nocert
    s.recv(1024)
  File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1226, in recv
    return self.read(buflen)
  File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1101, in read
    return self._sslobj.read(len)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLError: [SSL] called a function you should not call (_ssl.c:1108)
 server:  new connection from ('127.0.0.1', 56937)


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLError: [SSL: NO_SHARED_CIPHER] no shared cipher (_ssl.c:1108)
k


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ssl.SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:1108)
 server:  new connection from ('127.0.0.1', 56917)
 server: connection cipher is now ('TLS_AES_256_GCM_SHA384', 'TLSv1.3', 256)
 server: selected protocol is now None
 Connection reset by peer: ('127.0.0.1', 56917)
k


Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\threading.py", line 938, in _bootstrap_inner
    self.run()
  File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2386, in run


Traceback (most recent call last):
   File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 2219, in wrap_conn
    self.sslconn = self.server.context.wrap_socket(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1040, in _create
    self.do_handshake()
   File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
 ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
 server:  new connection from ('127.0.0.1', 56823)

@vstinner
Copy link
Member Author

vstinner commented Jul 9, 2019

The test failed on Windows, I cancelled the backport to 3.8.

lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
…ythonGH-14662)

Close the TLS connection in test_pha_required_nocert() of test_ssl to
fix a ResourceWarning.
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
…ythonGH-14662)

Close the TLS connection in test_pha_required_nocert() of test_ssl to
fix a ResourceWarning.
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants