Skip to content

Don't use SNI when host is an IP Address #278

Closed

Description

@sethmlarson

Per the SNI spec we shouldn't be using SNI when the hostname is an IP address.

Activity

  1. florimondmanca commented on Aug 26, 2019

    @florimondmanca
    Contributor

    Just wondering — what is SNI? 😄 Also, is there any more context on how this bug was discovered?

  2. sethmlarson commented on Aug 26, 2019

    @sethmlarson
    ContributorAuthor

    Server Name Identification (RFC 6066 Section 3) which disallows IP addresses (see the RFC search for "Literal IPv4"). It's set via server_hostname in Trio for example.

    Also I found this issue cuz I fixed it for urllib3. :)

  3. jlaine commented on Aug 26, 2019

    @jlaine

    How sure are you that this issue actually exists in httpx?

    Unless I'm mistaken connections are established using asyncio.open_connection which AFAICT does the Right Thing.

    I had a look with wireshark, and I only see the server_name extension in the ClientHello if I query a host name. If I connect to an IP address, the server_name extension is absent.

  4. florimondmanca commented on Aug 27, 2019

    @florimondmanca
    Contributor

    @sethmlarson I get the same behavior than @jlaine for the TrioBackend (#276): server_name is absent from the ClientHello if connecting to an IP address:

    import trio
    import httpx
    from httpx.concurrency.trio import TrioBackend
    
    
    async def main(url):
        async with httpx.AsyncClient(backend=TrioBackend()) as client:
            await client.get(url)
    
    
    trio.run(main, "https://8.8.8.8")
  5. sethmlarson commented on Aug 27, 2019

    @sethmlarson
    ContributorAuthor

    Nice, then we can probably close this issue.

  6. jlaine commented on Aug 28, 2019

    @jlaine

    This would definitely need to be re-visited if we ever start using server_hostname for asyncio or trio.

  7. sethmlarson commented on Aug 28, 2019

    @sethmlarson
    ContributorAuthor

    So do we not send SNI for any handshakes? Because that's an issue in itself.

  8. jlaine commented on Aug 28, 2019

    @jlaine

    We do send SNI when querying an FQDN, and don't when querying an IP (at least for asyncio). If you don't force asyncio's hand by setting server_hostname it does the right thing on its own.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions