Skip to content

Configuring TLS doesn't work if IPv6 IP address is passed in #2422

@bouk

Description

@bouk

I have some code like the following:

use tonic::transport::{Channel, Endpoint, ClientTlsConfig, Error};

fn connect_endpoint(url: String) -> Result<Channel, Error> {
    let channel = Endpoint::try_from(url)?
        .tls_config(ClientTlsConfig::new().with_enabled_roots())?
        .connect_lazy();
    Ok(channel)
}

This works fine if I pass a URL like https://example.com or http://127.0.0.1:1234 but it fails if I pass http://[::1]:1234 which is a valid URL.

The error is:

Error: 
   0: transport error
   1: invalid dns name

Which comes from this line:

domain: Arc::new(ServerName::try_from(domain)?.to_owned()),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions