-
Notifications
You must be signed in to change notification settings - Fork 5.3k
tls: add functionality to override requested server name in the upstream cluster #4973
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
Merged
htuch
merged 38 commits into
envoyproxy:master
from
vadimeisenbergibm:override_server_name
Nov 21, 2018
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
2fa0949
add ForwardRequestedServerName FilterState Object
vadimeisenbergibm 9701ce6
add functionality to override requested server name in the upstream c…
vadimeisenbergibm ab66f42
replace override_server_name with TransportSocketOptions
vadimeisenbergibm 5fe6e3e
fix compilation errors in tests
vadimeisenbergibm b6f32d7
fix format
vadimeisenbergibm 6aff2ea
fix compilation errors
vadimeisenbergibm 0b2a296
make overrideServerName() return const&
vadimeisenbergibm 6c9128d
make the parameter of newSSL() const&
vadimeisenbergibm dedd511
fix a compilation error
vadimeisenbergibm 27557de
fixed missed refactoring
vadimeisenbergibm b019a99
"refactor" a comment
vadimeisenbergibm 09af682
fix a typo
vadimeisenbergibm 8ff3b25
move stream_info/forward_requested_server_name to source/common/netwo…
vadimeisenbergibm cfbb753
StreamInfo::ForwardRequestedServerName -> Network::UpstreamServerName
vadimeisenbergibm 566570f
append missing StreamInfo namespace
vadimeisenbergibm 173849b
remove a leftover from the PR this PR was extracted from
vadimeisenbergibm 41cf2c7
fix format
vadimeisenbergibm 995d15e
remove names of the unused parameters
vadimeisenbergibm c8afa18
add comments
vadimeisenbergibm c9ed4a7
overrideServerName -> serverNameOverride
vadimeisenbergibm bdce6bb
make TransportSocketOptionsImpl::override_server_name_ const
vadimeisenbergibm 895dafb
std::string -> absl::string_view
vadimeisenbergibm 088f2d8
fix the hashKey() method
vadimeisenbergibm 88b3d31
update the comments - explanation about serverNameOverride
vadimeisenbergibm e9c0a87
use sizeof of a variable instead of hardcoded size value
vadimeisenbergibm 0fa1bd3
refactor scalar to byte vector conversion into pushScalarToByteVector()
vadimeisenbergibm 7109894
uint -> unsigned int
vadimeisenbergibm b8f0d3c
add missing includes
vadimeisenbergibm dddd8e3
fix static initialization problem
vadimeisenbergibm 2532513
fix format
vadimeisenbergibm 588fa98
PerConnectionCluster::Key -> PerConnectionCluster::key() in tests
vadimeisenbergibm 2f23141
add TODO replace long parameter lists with options objects
vadimeisenbergibm b31e6f6
use CONSTRUCT_ON_FIRST_USE macro
vadimeisenbergibm d84b467
combine pointer dereferencing and increment into one line
vadimeisenbergibm d6583b9
unsigned int -> uint32_t
vadimeisenbergibm 505cce2
Revert "make the parameter of newSSL() const&"
vadimeisenbergibm 58efa36
Merge branch 'master' into override_server_name
vadimeisenbergibm 7080014
replace v1 json with v2 yaml in DynamicHostRemoveWithTls test
vadimeisenbergibm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #pragma once | ||
|
|
||
| #include <inttypes.h> | ||
|
|
||
| #include <vector> | ||
|
|
||
| namespace Envoy { | ||
| template <typename T> void pushScalarToByteVector(T val, std::vector<uint8_t>& bytes) { | ||
| uint8_t* byte_ptr = reinterpret_cast<uint8_t*>(&val); | ||
| for (uint32_t byte_index = 0; byte_index < sizeof val; byte_index++) { | ||
| bytes.push_back(*byte_ptr++); | ||
| } | ||
| } | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #include "common/network/transport_socket_options_impl.h" | ||
|
|
||
| #include "common/common/scalar_to_byte_vector.h" | ||
| #include "common/common/utility.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Network { | ||
| void TransportSocketOptionsImpl::hashKey(std::vector<uint8_t>& key) const { | ||
| if (!override_server_name_.has_value()) { | ||
| return; | ||
| } | ||
|
|
||
| pushScalarToByteVector(StringUtil::CaseInsensitiveHash()(override_server_name_.value()), key); | ||
| } | ||
| } // namespace Network | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/network/transport_socket.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Network { | ||
|
|
||
| class TransportSocketOptionsImpl : public TransportSocketOptions { | ||
| public: | ||
| TransportSocketOptionsImpl(absl::string_view override_server_name = "") | ||
| : override_server_name_(override_server_name.empty() | ||
| ? absl::nullopt | ||
| : absl::optional<std::string>(override_server_name)) {} | ||
|
|
||
| // Network::TransportSocketOptions | ||
| const absl::optional<std::string>& serverNameOverride() const override { | ||
| return override_server_name_; | ||
| } | ||
| void hashKey(std::vector<uint8_t>& key) const override; | ||
|
|
||
| private: | ||
| const absl::optional<std::string> override_server_name_; | ||
| }; | ||
|
|
||
| } // namespace Network | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #include "common/network/upstream_server_name.h" | ||
|
|
||
| #include "common/common/macros.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Network { | ||
|
|
||
| const std::string& UpstreamServerName::key() { | ||
| CONSTRUCT_ON_FIRST_USE(std::string, "envoy.network.upstream_server_name"); | ||
| } | ||
| } // namespace Network | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/stream_info/filter_state.h" | ||
|
|
||
| #include "absl/strings/string_view.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Network { | ||
|
|
||
| /** | ||
| * Server name to set in the upstream connection. The filters like tcp_proxy should use this | ||
lizan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * value to override the server name specified in the upstream cluster, for example to override | ||
| * the SNI value in the upstream TLS context. | ||
| */ | ||
| class UpstreamServerName : public StreamInfo::FilterState::Object { | ||
| public: | ||
| UpstreamServerName(absl::string_view server_name) : server_name_(server_name) {} | ||
| const std::string& value() const { return server_name_; } | ||
| static const std::string& key(); | ||
|
|
||
| private: | ||
| const std::string server_name_; | ||
| }; | ||
|
|
||
| } // namespace Network | ||
| } // namespace Envoy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
|
|
||
| #include "common/ssl/context_manager_impl.h" | ||
|
|
||
| #include "absl/types/optional.h" | ||
| #include "openssl/ssl.h" | ||
|
|
||
| namespace Envoy { | ||
|
|
@@ -41,7 +42,7 @@ struct SslStats { | |
|
|
||
| class ContextImpl : public virtual Context { | ||
| public: | ||
| virtual bssl::UniquePtr<SSL> newSsl() const; | ||
| virtual bssl::UniquePtr<SSL> newSsl(absl::optional<std::string> override_server_name) const; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const ref for parameter |
||
|
|
||
| /** | ||
| * Logs successful TLS handshake and updates stats. | ||
|
|
@@ -142,7 +143,7 @@ class ClientContextImpl : public ContextImpl, public ClientContext { | |
| ClientContextImpl(Stats::Scope& scope, const ClientContextConfig& config, | ||
| TimeSource& time_source); | ||
|
|
||
| bssl::UniquePtr<SSL> newSsl() const override; | ||
| bssl::UniquePtr<SSL> newSsl(absl::optional<std::string> override_server_name) const override; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const ref for parameter (everywhere) |
||
|
|
||
| private: | ||
| const std::string server_name_indication_; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.