You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
if check_hostname is true, context can't be used for server purposes #65224
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2014-03-22.11:35:11.719>labels= ['type-bug', 'library']
title="if check_hostname is true, context can't be used for server purposes"updated_at=<Date2014-03-22.17:25:12.431>user='https://github.com/pitrou'
On a SSLContext with check_hostname = True, calling wrap_socket(..., server_side=True) will complain that no server hostname has been passed. This should only be done for client sockets.
(of course, it may be better to have separate contexts for client and server use, but it can also be convenient to use a single context - especially when doing tests :-))
The error message is misleading in server mode. I propose:
a server-specific error message like: "check_hostname cannot be used with server_side=True; disable check_hostname or use a separate server context".
SSLContext.check_hostname docs addition like: "Hostname checking applies only to client-side connections; a context with it enabled cannot be used with server_side=True, so use a separate context for servers."
Activity
pitrou commentedon Mar 22, 2014
On a SSLContext with check_hostname = True, calling wrap_socket(..., server_side=True) will complain that no server hostname has been passed. This should only be done for client sockets.
pitrou commentedon Mar 22, 2014
(of course, it may be better to have separate contexts for client and server use, but it can also be convenient to use a single context - especially when doing tests :-))
photon-e commentedon Feb 18, 2023
@ezio-melotti looks like this issue needs to be closed
vasiliyk commentedon Oct 24, 2026
This still reproduces on 3.16.0a1+dev:
The error message is misleading in server mode. I propose:
SSLContext.check_hostnamedocs addition like: "Hostname checking applies only to client-side connections; a context with it enabled cannot be used with server_side=True, so use a separate context for servers."I'm happy to open a PR.