(self)
| 2109 | self.assertTrue(s.getpeercert()) |
| 2110 | |
| 2111 | def test_non_blocking_connect_ex(self): |
| 2112 | # Issue #11326: non-blocking connect_ex() should allow handshake |
| 2113 | # to proceed after the socket gets ready. |
| 2114 | s = test_wrap_socket(socket.socket(socket.AF_INET), |
| 2115 | cert_reqs=ssl.CERT_REQUIRED, |
| 2116 | ca_certs=SIGNING_CA, |
| 2117 | do_handshake_on_connect=False) |
| 2118 | self.addCleanup(s.close) |
| 2119 | s.setblocking(False) |
| 2120 | rc = s.connect_ex(self.server_addr) |
| 2121 | # EWOULDBLOCK under Windows, EINPROGRESS elsewhere |
| 2122 | self.assertIn(rc, (0, errno.EINPROGRESS, errno.EWOULDBLOCK)) |
| 2123 | # Wait for connect to finish |
| 2124 | select.select([], [s], [], 5.0) |
| 2125 | # Non-blocking handshake |
| 2126 | while True: |
| 2127 | try: |
| 2128 | s.do_handshake() |
| 2129 | break |
| 2130 | except ssl.SSLWantReadError: |
| 2131 | select.select([s], [], [], 5.0) |
| 2132 | except ssl.SSLWantWriteError: |
| 2133 | select.select([], [s], [], 5.0) |
| 2134 | # SSL established |
| 2135 | self.assertTrue(s.getpeercert()) |
| 2136 | |
| 2137 | def test_connect_with_context(self): |
| 2138 | # Same as test_connect, but with a separately created context |
nothing calls this directly
no test coverage detected