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

Provide hostname for SNI #15

Closed
mmastrac opened this issue Sep 28, 2023 · 5 comments
Closed

Provide hostname for SNI #15

mmastrac opened this issue Sep 28, 2023 · 5 comments

Comments

@mmastrac
Copy link
Contributor

The hostname negotiation for SNI may be different from the connection address. For example, a client may connect by IP to a service and provide an unresolved hostname on connection. As in #14, this SNI negotation result may need to provided as part of the handshake promise.

@jasnell
Copy link
Collaborator

jasnell commented Sep 28, 2023

Absolutely agree. I'd like to see hostname and ALPN accepted as arguments.

For background, we very intentionally limited the options that can be specified on connect() initially because we didn't want to go the Node.js route and offer every option anyone might ever want without clearly understanding what would actually be the most useful. We want to be far more selective about how these are added.

I think it is safe to say, however, that SNI and ALPN are definitely Must Haves.

@mmastrac
Copy link
Contributor Author

Definitely -- both of those may be required for a successful HTTP/2 or gRPC connection, for example. In terms of TLS options, I'd suggest these are probably the two most important and most common.

@jasnell
Copy link
Collaborator

jasnell commented Sep 28, 2023

Would you be interested in opening a PR adding these? I think we ought to be able to keep it pretty simple, e.g.,

const socket = connect('...', { secureTransport: 'on', sni: 'example.org', alpn: ['h1', 'h2'] });
await socket.opened; // see https://github.com/wintercg/proposal-sockets-api/pull/12
console.log(socket.info.sni);  // the negotiated sni. undefined before handshake is complete
console.log(socket.info.alpn); // the negotiated alpn. undefined before handshake is complete

@mmastrac
Copy link
Contributor Author

@jasnell Opened a PR for it. Some further comments in #18

@jasnell
Copy link
Collaborator

jasnell commented Nov 5, 2023

This has been added.

@jasnell jasnell closed this as completed Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants