Skip to content

check_hostname defaults to true when true is invalid #160605

Open

Description

@mdonoughe

Bug report

#156793 introduces a regression where if you had code like this

asyncio.open_connection(host, port, ssl=ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT), server_hostname="")

you start getting ValueError: check_hostname requires server_hostname starting in 3.14.8 when the same code worked in 3.14.7.

I understand there was a change made for security reasons. If somebody has enabled check_hostname they expect hostname validation. However, this code does not enable check_hostname. It's being defaulted somewhere. The previous code was intentionally not checking the hostname.

I don't know how common this is. In my case, server_hostname is set to empty because the target service behaves incorrectly if it receives SNI, and hostname validation is not desired because the presented certificate is valid for no names. It's a server certificate, but it uses the client certificate validation pattern where the certificate must be signed by the expected CA.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Activity

  1. jadhavroshani713-sys commented on Oct 24, 2026

    @jadhavroshani713-sys

    Hi, I'd like to contribute to investigating this regression.

    I plan to create a minimal reproducer, inspect the changes introduced by #156793, and add a regression test.

    Before submitting a PR, could a maintainer confirm the intended behavior for server_hostname="" when check_hostname=True? I understand that the change addresses a security issue, so I'd like to ensure any proposed fix preserves the security guarantees while addressing the reported compatibility regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions