Project

General

Profile

Feature #15215

HTTPS server name indication (SNI): explicit server_name in Net::HTTP

Added by aspettl (Aaron Spettl) about 1 year ago. Updated 5 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:89305]

Description

Current behavior and problem:
At the moment, the host name or IP address given in the URL is used to provide the server name for SNI in HTTPS connections. While this behavior is sufficient in most cases, establishing a connection to a fixed IP using a certain server name is not possible.

Proposed solution:
Decouple the server name used for SNI from the address used for connecting. Add a new ssl_server_name attribute in Net::HTTP that defaults to the address (so the default behavior stays exactly the same).

Notes

  • There are scenarios where a client would like to select a specific host when e.g. DNS round robin is configured. Examples: fallback strategies, monitoring of individual hosts.
  • This has nothing to do with the HTTP "Host" header, which one needs to set additionally.

For my "proposed solution", a patch is attached (or see https://github.com/ruby/ruby/pull/1977).
Please let me know about any ideas for improvement or other approaches, thanks!


Files

ssl_server_name.patch (2.17 KB) ssl_server_name.patch Patch: Introduce new attribute ssl_server_name in Net::HTTP aspettl (Aaron Spettl), 10/07/2018 09:15 AM

Related issues

Is duplicate of Ruby master - Feature #5180: net/http の接続時に用いる IP アドレスの指定ClosedActions

Associated revisions

Revision 54072e32
Added by naruse (Yui NARUSE) 5 days ago

Add ipaddr optional parameter to Net::HTTP#start

to replace the address for TCP/IP connection [Feature #5180]

There're 3 layers of hostname:

  • host address for TCP/IP
  • TLS server name
  • HTTP Host header value To test DNS round robin or check server certificate from server local, people sometimes want to connect server with given IP address but keep TLS server name and HTTP Host header value.

closes [Feature #15215]
closes https://github.com/ruby/ruby/pull/1893
closes https://github.com/ruby/ruby/pull/1977

History

Updated by aspettl (Aaron Spettl) about 1 year ago

aspettl (Aaron Spettl) wrote:

Proposed solution:
Decouple the server name used for SNI from the address used for connecting. Add a new ssl_server_name attribute in Net::HTTP that defaults to the address (so the default behavior stays exactly the same).

One comment on a corner case:
When ssl_server_name is set, then it is always used for verifying the certificate - even when OpenSSL is old and does not support SNI yet. In such a case, the certificate presented by the server will not match probably (and, thus, verification fails). I think this is desired behavior.

Updated by aspettl (Aaron Spettl) 12 months ago

I still like to have this feature. Any opinion on this? Especially naruse (Yui NARUSE) as a maintainer of lib/net/http(s).rb?

Thanks!

Updated by waf (felix wong) 4 months ago

aspettl (Aaron Spettl) wrote:

I still like to have this feature. Any opinion on this? Especially naruse (Yui NARUSE) as a maintainer of lib/net/http(s).rb?

Thanks!

+1 as well

#4

Updated by naruse (Yui NARUSE) 6 days ago

  • Is duplicate of Feature #5180: net/http の接続時に用いる IP アドレスの指定 added

Updated by naruse (Yui NARUSE) 5 days ago

Duplicated with #5180.
Since there're 3 layers:

  • host address for TCP/IP
  • TLS server name
  • HTTP Host header

In this use case, I think you wan to set different value for IP layer.
If you forget to change HTTP Host header, it will cause unexpected result if the server uses VirtualHost.

I understand this ticket and related GitHub PRs as +1 for #5180, and I reopen it and commit.

#6

Updated by naruse (Yui NARUSE) 5 days ago

  • Status changed from Open to Closed

Applied in changeset git|54072e329cab7207fba133caba4fc12b45add8f9.


Add ipaddr optional parameter to Net::HTTP#start

to replace the address for TCP/IP connection [Feature #5180]

There're 3 layers of hostname:

  • host address for TCP/IP
  • TLS server name
  • HTTP Host header value To test DNS round robin or check server certificate from server local, people sometimes want to connect server with given IP address but keep TLS server name and HTTP Host header value.

closes [Feature #15215]
closes https://github.com/ruby/ruby/pull/1893
closes https://github.com/ruby/ruby/pull/1977

Also available in: Atom PDF