For me, this error message was caused by using ssl.Purpose.CLIENT_AUTH instead of ssl.Purpose.SERVER_AUTH in my ssl.create_default_context() arguments. Clients should use ssl.Purpose.SERVER_AUTH because they are authorizing the servers they are communicating with, not ssl.Purpose.CLIENT_AUTH, and vice versa for servers.

import socket
import ssl
ME_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sslContext = ssl.create_default_context(purpose = ssl.Purpose.SERVER_AUTH, cafile = 'C://...//CACert.pem', capath = None, cadata = None)
sslContext.load_cert_chain(certfile = 'C://...//serverCert.pem')
ME_SSL = sslContext.wrap_socket(ME_socket, server_side = False, server_hostname = 'MY_IP')
Answer from mwolfe 11 on Stack Overflow
🌐
GitHub
github.com › Vaelor › python-mattermost-driver › issues › 115
Failed to establish websocket connection: Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801) · Issue #115 · Vaelor/python-mattermost-driver
March 3, 2022 - I get this error when using Python 3.10: Failed to establish websocket connection: Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801) Is there any websocket option I can ...
Author   oculos
🌐
Gentoo
bugs.gentoo.org › 835498
835498 – dev-python/imapclient doesn't work with python3.10 (ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context)
June 21, 2022 - Gentoo's Bugzilla – Bug 835498 dev-python/imapclient doesn't work with python3.10 (ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context) Last modified: 2022-06-21 05:48:07 UTC node [vulture]
🌐
GitHub
github.com › bamthomas › aioimaplib › issues › 78
Py 3.10: ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context · Issue #78 · iroco-co/aioimaplib
July 6, 2022 - 2022-07-06 11:27:01 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection transport, protocol = await self._create_connection_transport( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport await waiter File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 637, in _on_handshake_complete raise handshake_exc File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 682, in _process_write_b
Author   frenck
🌐
GitHub
github.com › python › cpython › issues › 96972
Confusing behavior of ssl.create_default_context() · Issue #96972 · python/cpython
September 20, 2022 - >>> ssl.create_default_context(ssl.Purpose.CLIENT_AUTH).wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File ".../python3.10/ssl.py", line 527, in wrap_bio return self.sslobject_class._create( File ".../python3.10/ssl.py", line 866, in _create sslobj = context._wrap_bio( ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801)
Author   piannucci
🌐
Fedora Project
src.fedoraproject.org › rpms › python-aiosmtpd › c › 438cff81c0ac42d499f7321d533590c0231c6ee6
Commit - rpms/python-aiosmtpd - 438cff81c0ac42d499f7321d533590c0231c6ee6 - src.fedoraproject.org
Avoid SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context · Build completed · success · Built as python-aiosmtpd-1.4.2-6.fc35 · 3 years ago · Build completed · success · Built as python-aiosmtpd-1.4.2-6.fc36 · 3 years ago · 284.patch · file added ·
🌐
GitHub
github.com › mjs › imapclient › issues › 466
ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context · Issue #466 · mjs/imapclient
March 1, 2022 - Option for create_default_context() and SSLContext.load_default_certs(). This value indicates that the context may be used to authenticate web servers (therefore, it will be used to create client-side sockets).
Author   alkim0
🌐
Symphony
forum.developers.symphony.com › question › 1420317824043192320 › python-3-10-error-protocol-tls-server
Symphony Dev Forum | Python 3.10 Error: PROTOCOL_TLS_SERVER
symphony.bdk.core.auth.bot_authenticator - INFO - Retrying symphony.bdk.core.auth.bot_authenticator.BotAuthenticatorRsa._authenticate_and_get_token in 256.0 seconds as it raised ClientConnectorSSLError: Cannot connect to host XXXXXX-test.symphony.com:443 ssl:default [Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801)]. In the same environment, my friend does not have this issue and his bot is working without any error.
🌐
GitHub
github.com › OpenLEADR › openleadr-python › issues › 122
Python 3.10 VEN - Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801) · Issue #122 · OpenLEADR/openleadr-python
June 16, 2022 - ******************************************************************************** Could not connect to server with URL https://localhost:8500/OpenADR2/Simple/2.0b: ClientConnectorSSLError: Cannot connect to host localhost:8500 ssl:default [Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801)] No RegistrationID received from the VTN, aborting.
Author   ebencollins
Find elsewhere
🌐
GitHub
github.com › MrAsterisco › homebridge-hisense-tv › issues › 49
Cannot create a client socket with a PROTOCOL_TLS_SERVER context · Issue #49 · MrAsterisco/homebridge-hisense-tv
July 22, 2023 - / Describe The Bug: When running python3.10 hisensetv.py --authorize it errors out with cannot "ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801)" so I am unable to create a binding with the TV. ...
Author   samjones108
🌐
GitHub
github.com › aio-libs › aiosmtpd › actions › runs › 1266108378
Avoid SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context · aio-libs/aiosmtpd@e302182
A reimplementation of the Python stdlib smtpd.py based on asyncio. - Avoid SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context · aio-libs/aiosmtpd@e302182
Author   aio-libs
🌐
GitHub
github.com › ansible-collections › community.general › issues › 4974
lxd_container: ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context · Issue #4974 · ansible-collections/community.general
- hosts: localhost connection: local tasks: - name: Create a started container community.general.lxd_container: name: mycontainer url: https://100.115.92.193:8443 client_cert: "{{ lookup('env', 'HOME') }}/.config/lxc/client.crt" client_key: "{{ lookup('env', 'HOME') }}/.config/lxc/client.key" trust_password: xxxxxx ignore_volatile_options: true state: started source: type: image mode: pull server: https://images.linuxcontainers.org protocol: simplestreams # if you get a 404, try setting protocol: simplestreams alias: ubuntu/jammy/cloud profiles: ["default"] wait_for_ipv4_addresses: true
🌐
Python
docs.python.org › 3 › library › ssl.html
ssl — TLS/SSL wrapper for socket objects — Python 3.14.4 ...
Deprecated since version 3.10: TLS clients and servers require different default settings for secure communication. The generic TLS protocol constant is deprecated in favor of PROTOCOL_TLS_CLIENT and PROTOCOL_TLS_SERVER. ... Auto-negotiate the highest protocol version that both the client and server support, and configure the context client-side connections.
🌐
YouTube
youtube.com › watch
Troubleshooting: Why You Cannot Create a Client Socket with ...
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
🌐
GitHub
github.com › aio-libs › aiosmtpd › issues › 277
aiosmtpd test suite fails on Python 3.10 · Issue #277 · aio-libs/aiosmtpd
July 27, 2021 - =========================== short test summary info ============================ FAILED aiosmtpd/tests/test_server.py::TestUnixSocketController::test_server_creation_ssl FAILED aiosmtpd/tests/test_smtp.py::TestAuthMechanisms::test_byclient[login-False] FAILED aiosmtpd/tests/test_smtp.py::TestAuthArgs::test_warn_authreqnotls - as... ERROR aiosmtpd/tests/test_smtps.py::TestSMTPS::test_smtps - ssl.SSLError: Can... ERROR aiosmtpd/tests/test_starttls.py::TestNoTLS::test_disabled_tls - OSError...
Author   Conan-Kudo
🌐
Fedora Project
src.fedoraproject.org › rpms › python-aiosmtpd › blob › 438cff81c0ac42d499f7321d533590c0231c6ee6 › f › 284.patch
Tree - rpms/python-aiosmtpd - src.fedoraproject.org
--- aiosmtpd/controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiosmtpd/controller.py b/aiosmtpd/controller.py index 79bdbd04..30fd4a11 100644 --- a/aiosmtpd/controller.py +++ b/aiosmtpd/controller.py @@ -424,7 +424,7 @@ def _trigger_server(self): hostname = self.hostname or self._localhost with ExitStack() as stk: s = stk.enter_context(create_connection((hostname, self.port), 1.0)) - if self.ssl_context: + if self.ssl_context and self.ssl_context.protocol != ssl.PROTOCOL_TLS_SERVER: s = stk.enter_context(self.ssl_context.wrap_socket(s)) s.recv(1024)
🌐
GitHub
github.com › Chaffelson › nipyapi › issues › 370
Cannot connect with TLS secured NiFi 2.x using nipyapi.security.set_service_ssl_context and Python 3.12 · Issue #370 · Chaffelson/nipyapi
October 13, 2024 - This worked for me when creating an ssl_context manually with Purpose.SERVER_AUTH instead of the Purpose.CLIENT_AUTH that NiPyApi uses when a cert/key are specified in the nipyapi.security.set_service_ssl_context call. use SmallStep CA & CLI to create a custom CA and TLS certificates
Author   ChrisSamo632
🌐
Python Forum
python-forum.io › thread-15567.html
SSL not working with Python 3.7
January 22, 2019 - I started to learn python and sockets those days and I made a simple client-server app just to make some tests and it works fine with Python 3.6, but gives me error in the newest version. I make the code while studying the Python's docs. I'm using Py...