Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/admin-guide/files/records.config.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3636,6 +3636,9 @@ Client-Related Configuration
``host``
This is the default. The value of the ``Host`` field in the proxy request is used.

``server_name``
The SNI value of the inbound TLS connection is used.

``remap``
The remapped upstream name is used.

Expand Down
2 changes: 2 additions & 0 deletions proxy/http/HttpSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4874,6 +4874,8 @@ HttpSM::get_outbound_sni() const
int len;
char const *ptr = t_state.hdr_info.server_request.host_get(&len);
zret.assign(ptr, len);
} else if (ua_txn && !strcmp(policy, "server_name"_tv)) {
zret.assign(ua_txn->get_netvc()->get_server_name(), ts::TextView::npos);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, are we actually strcmp()'ing these policy strings (from the yaml) on every request??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the policy is not empty, unfortunately, yes. I agree with we should avoid these strcmp with fixed strings except @... format.

https://docs.trafficserver.apache.org/en/latest/admin-guide/files/records.config.en.html?highlight=proxy.config.ssl.client.sni_policy#proxy-config-ssl-client-sni-policy

} else if (policy.front() == '@') { // guaranteed non-empty from previous clause
zret = policy.remove_prefix(1);
} else {
Expand Down
26 changes: 25 additions & 1 deletion tests/gold_tests/tls/tls_verify_override_base.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'''

# Define default ATS
ts = Test.MakeATSProcess("ts", select_ports=True)
ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True)
server_foo = Test.MakeOriginServer("server_foo",
ssl=True,
options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory),
Expand Down Expand Up @@ -84,12 +84,18 @@
ts.Disk.remap_config.AddLine(
'map /snipolicyfoohost https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format(
server_bar.Variables.SSL_Port))
ts.Disk.remap_config.AddLine(
'map /snipolicyfooservername https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=server_name'.format(
server_bar.Variables.SSL_Port))
ts.Disk.remap_config.AddLine(
'map /snipolicybarremap https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=remap'.format(
server_bar.Variables.SSL_Port))
ts.Disk.remap_config.AddLine(
'map /snipolicybarhost https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format(
server_bar.Variables.SSL_Port))
ts.Disk.remap_config.AddLine(
'map /snipolicybarservername https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=server_name'.format(
server_bar.Variables.SSL_Port))

ts.Disk.ssl_multicert_config.AddLine(
'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key'
Expand Down Expand Up @@ -193,6 +199,15 @@
tr.StillRunningAfter = ts
tr.Processes.Default.Streams.stdout = Testers.ContainsExpression("Could not connect", "Curl attempt should fail")

# Should fail
tr = Test.AddTestRun("foo-to-bar-sni-policy-servername")
tr.Processes.Default.Command = "curl -k --resolv foo.com:{0}:127.0.0.1 https://foo.com:{0}/snipolicybarservername".format(
ts.Variables.ssl_port)
tr.ReturnCode = 0
tr.StillRunningAfter = server
tr.StillRunningAfter = ts
tr.Processes.Default.Streams.stdout = Testers.ContainsExpression("Could not connect", "Curl attempt should fail")

# Should fail
tr = Test.AddTestRun("bar-to-foo-sni-policy-remap")
tr.Processes.Default.Command = "curl -k -H \"host: bar.com\" http://127.0.0.1:{0}/snipolicyfooremap".format(ts.Variables.port)
Expand All @@ -209,6 +224,15 @@
tr.StillRunningAfter = ts
tr.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could not connect", "Curl attempt should succeed")

# Should succeed
tr = Test.AddTestRun("bar-to-foo-sni-policy-servername")
tr.Processes.Default.Command = "curl -k --resolv bar.com:{0}:127.0.0.1 https://bar.com:{0}/snipolicyfooservername".format(
ts.Variables.ssl_port)
tr.ReturnCode = 0
tr.StillRunningAfter = server
tr.StillRunningAfter = ts
tr.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could not connect", "Curl attempt should succeed")


# Over riding the built in ERROR check since we expect some cases to fail

Expand Down