dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.19k stars 1.56k forks source link

Custom SNI (Server Name Indication) support in HttpClient #44122

Open secondaryconstructor opened 3 years ago

secondaryconstructor commented 3 years ago

If we have several virtual hosts (whose name is different from HTTPS endpoint name) on server, I find no way to set custom SNIs in HttpClient while establishing a TLS connection. Any suggestions if it is anyhow possible?

I tried adding host in headers but it doesn't work (verified using wireshark).

Currently used Dart version: Dart 2.10.3, stable channel.

mraleph commented 3 years ago

This is not supported for HttpClient unfortunately. SecureSocket supports this - but this is not exposed through HttpClient APIs.

aam commented 3 years ago

Add host parameter to https://api.dart.dev/stable/2.10.3/dart-io/HttpClient/openUrl.html ? Or perhaps add HttpClient::connect that takes open SecureSocket?

b055man commented 2 months ago

This likely could be achieved using a custom socket factory and reusing sockets, with that change introduced https://github.com/dart-lang/sdk/issues/55562 The downside is it's just been merged and there's only a couple of pre-release Flutter versions that incorporate that change (e.g. 3.24.0-0.2.pre) EDIT: 3.24 just landed and it enables that.