This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: BlockingIOError: [Errno 11] Resource temporarily unavailable when performing SSL handshake on Solaris
Type: behavior Stage:
Components: SSL Versions: Python 3.10, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, florinspatar
Priority: normal Keywords:

Created on 2021-10-27 08:38 by florinspatar, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
client.py florinspatar, 2021-10-27 08:38 client sample
Messages (2)
msg405076 - (view) Author: Florin Spătar (florinspatar) * Date: 2021-10-27 08:38
Trying to connect to an uWSGI (or any other) server, from Solaris, will fail with the following error:

-bash-3.00# /opt/opsware/agent/bin/python3 client.py 
/tmp/client.py:9: DeprecationWarning: ssl.PROTOCOL_TLS is deprecated
  context = ssl.SSLContext(ssl.PROTOCOL_TLS)
Exception in thread Thread-1 (make_connection):
Traceback (most recent call last):
  File "/opt/opsware/agent/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/opt/opsware/agent/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/tmp/client.py", line 13, in make_connection
    with context.wrap_socket(sock, server_hostname=hostname) as ssock:
  File "/opt/opsware/agent/lib/python3.10/ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "/opt/opsware/agent/lib/python3.10/ssl.py", line 1070, in _create
    self.do_handshake()
  File "/opt/opsware/agent/lib/python3.10/ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
BlockingIOError: [Errno 11] Resource temporarily unavailable

I used the following client code (based on https://docs.python.org/3.10/library/ssl.html#socket-creation):

import socket
import ssl
import threading

hostname = '192.168.135.9'
port = 1004

def make_connection():
	context = ssl.SSLContext(ssl.PROTOCOL_TLS)

	with socket.create_connection((hostname, port)) as sock:
		sock.settimeout(300) # use non-blocking I/O
		with context.wrap_socket(sock, server_hostname=hostname) as ssock:
			print(ssock.version())


t=threading.Thread(target=make_connection)
t.start()
t.join()

This works fine on multiple Linux distros, AIX, and HP-UX. It even seems to work on Solaris Sparc. There seems to be an issue only on Solaris (5.10/5.11) x86.
Furthermore, in order to reproduce the issue, the SSL handshake needs to be performed from a thread and use non-blocking I/O. If I use blocking I/O or don't use thread, the issue doesn't reproduce anymore.

The issues first started to appear in python 3.8.5 when I switched from openssl 1.0.2u to 1.1.1k. The issue is still reproducible with python 3.10 and openssl 3.0.0
msg405080 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-10-27 10:12
Thanks for the detailed bug report.

Since the code works on Linux and other platforms as well as OpenSSL 1.0.2, it is likely a platform bug or a platform-specific issue with OpenSSL. Unfortunately I don't know how to investigate this issue.
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89785
2021-10-27 10:12:52christian.heimessetassignee: christian.heimes ->
messages: + msg405080
2021-10-27 08:38:26florinspatarcreate