Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/tls: support different protocols for different server names #17666

Closed
nhooyr opened this issue Oct 29, 2016 · 2 comments
Closed

crypto/tls: support different protocols for different server names #17666

nhooyr opened this issue Oct 29, 2016 · 2 comments

Comments

@nhooyr
Copy link
Contributor

nhooyr commented Oct 29, 2016

I've written a server that accepts a TLS connection, connects to a address based on the TLS connections server name and ALPN proto, and then copies all data between the two connections.
https://github.com/nhooyr/tlsmuxd

The problem that I am having is for the following configuration:

{
    "email": "user@example.com",
    "cacheDir": "/var/lib/tlsmuxd",
    "protos": [{
        "name": "h2",
        "hosts": {
            "example.com": "localhost:8080",
            "www.example.com": "localhost:8080",
        }
    }, {
        "name": "http/1.1",
        "hosts": {
            "example.com": "localhost:8083",
            "www.example.com": "localhost:8083",
            "example2.com": "localhost:8084",
            "www.example2.com": "localhost:8084"
        }
    }],
    "defaultProto": "http/1.1"
}

Now say a user connects to my server with their ALPN protos as ["h2", "http/1.1"] and server name as "example2.com". According to the above configuration, a connection to localhost:8084 should be made and then all data between the user and localhost:8084 connections should be copied. The problem is that crypto/tls does not allow for dynamic ALPN. So the "h2" protocol will always be selected and then the user will be disconnected because "example2.com" does not exist for "h2".

So I'd like is to be able to offer different protocols for different server names instead of having it static. This isn't a severe problem for me because since I use Go, I'll always be able to serve both "http/1.1" and "h2". However, it feels ugly because say I have the "ssh" protocol defined (I tunnel SSH through TLS when I need to get around a strict network) for "example.com", then if someone connects with Server Name as "example2.com", even though my server cannot actually serve it SSH, it still advertises it.

@bradfitz
Copy link
Contributor

Isn't this addressed by Config.GetConfigForClient from https://go-review.googlesource.com/30790?

@nhooyr
Copy link
Contributor Author

nhooyr commented Oct 29, 2016

Oh, I was not aware of that. Will take a look.

edit: looks like it does. thanks!

@nhooyr nhooyr closed this as completed Oct 29, 2016
@golang golang locked and limited conversation to collaborators Oct 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants