[issue44229] Intermittent connection errors in ssl tests on macOS CI

Erlend E. Aasland report at bugs.python.org
Sat May 29 17:44:55 EDT 2021


Erlend E. Aasland <erlend.aasland at innova.no> added the comment:

Here's the output when with test.support.verbose = True:

test_ssl: testing with 'OpenSSL 1.1.1k  25 Mar 2021' (1, 1, 1, 11, 15)                                                 
          under Mac ('11.3.1', ('', '', ''), 'x86_64')                                                                 
          HAS_SNI = True                                                                                               
          OP_ALL = 0x80000054                                                                                          
          OP_NO_TLSv1_1 = 0x10000000                                                                                   
test_get_server_certificate (test.test_ssl.SimpleBackgroundTests) ...  server:  new connection from ('127.0.0.1', 51163)

 server:  bad connection attempt from ('127.0.0.1', 51163):                                                            
Traceback (most recent call last):
   File "/Users/erlendaasland/src/cpython-ssl/Lib/test/test_ssl.py", line 2366, in wrap_conn                           
    self.sslconn = self.server.context.wrap_socket(
   File "/Users/erlendaasland/src/cpython-ssl/Lib/ssl.py", line 518, in wrap_socket                                    
    return self.sslsocket_class._create(
   File "/Users/erlendaasland/src/cpython-ssl/Lib/ssl.py", line 1070, in _create                                       
    self.do_handshake()
   File "/Users/erlendaasland/src/cpython-ssl/Lib/ssl.py", line 1339, in do_handshake                                  
    self._sslobj.do_handshake()
 OSError: [Errno 41] Protocol wrong type for socket                                                                    
ERROR

======================================================================                                                 
ERROR: test_get_server_certificate (test.test_ssl.SimpleBackgroundTests)                                               
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/erlendaasland/src/cpython-ssl/Lib/test/test_ssl.py", line 2130, in test_get_server_certificate          
    _test_get_server_certificate(self, *self.server_addr, cert=SIGNING_CA)
  File "/Users/erlendaasland/src/cpython-ssl/Lib/test/test_ssl.py", line 2327, in _test_get_server_certificate         
    pem = ssl.get_server_certificate((host, port), ca_certs=cert)
  File "/Users/erlendaasland/src/cpython-ssl/Lib/ssl.py", line 1520, in get_server_certificate
    with create_connection(addr, timeout=timeout) as sock:
  File "/Users/erlendaasland/src/cpython-ssl/Lib/socket.py", line 844, in create_connection                            
    raise err
  File "/Users/erlendaasland/src/cpython-ssl/Lib/socket.py", line 832, in create_connection                            
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

---------------------------------------------------------------------- 


The mock server fails with EPROTOTYPE, thus the client fails with connection refused.

I found similar issues after doing some googling:
- http://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/
- https://github.com/benoitc/gunicorn/issues/1487#issuecomment-333680970

This might be the same macOS bug.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44229>
_______________________________________


More information about the Python-bugs-list mailing list