grpc 1.22.0 → 1.23.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +487 -649
- data/include/grpc/grpc_security.h +25 -0
- data/include/grpc/impl/codegen/grpc_types.h +11 -2
- data/include/grpc/impl/codegen/port_platform.h +12 -0
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +477 -182
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +25 -16
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +11 -6
- data/src/core/ext/filters/client_channel/connector.h +10 -2
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +3 -3
- data/src/core/ext/filters/client_channel/http_proxy.cc +9 -10
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -17
- data/src/core/ext/filters/client_channel/lb_policy.h +36 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +22 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +86 -52
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +7 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +73 -72
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -12
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +25 -101
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +5 -5
- data/src/core/ext/filters/client_channel/parse_address.cc +29 -26
- data/src/core/ext/filters/client_channel/resolver.h +3 -11
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +405 -82
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +44 -51
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +0 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +0 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +11 -6
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +130 -65
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +8 -3
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +31 -14
- data/src/core/ext/filters/client_channel/resolver_factory.h +4 -0
- data/src/core/ext/filters/client_channel/resolver_registry.cc +11 -0
- data/src/core/ext/filters/client_channel/resolver_registry.h +3 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +10 -49
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +1 -14
- data/src/core/ext/filters/client_channel/retry_throttle.h +2 -3
- data/src/core/ext/filters/client_channel/subchannel.cc +65 -58
- data/src/core/ext/filters/client_channel/subchannel.h +65 -45
- data/src/core/ext/filters/client_channel/subchannel_interface.h +15 -30
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +262 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +4 -5
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +140 -152
- data/src/core/ext/filters/max_age/max_age_filter.cc +3 -3
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +3 -4
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +63 -38
- data/src/core/ext/transport/chttp2/transport/context_list.cc +3 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +8 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +7 -0
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +37 -22
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +136 -81
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -0
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +7 -166
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +41 -15
- data/src/core/ext/transport/chttp2/transport/internal.h +13 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +35 -22
- data/src/core/ext/transport/chttp2/transport/stream_map.cc +28 -18
- data/src/core/ext/transport/chttp2/transport/writing.cc +1 -0
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -1
- data/src/core/lib/channel/channelz.cc +80 -33
- data/src/core/lib/channel/channelz.h +28 -13
- data/src/core/lib/compression/compression.cc +1 -2
- data/src/core/lib/compression/compression_args.cc +13 -6
- data/src/core/lib/compression/compression_args.h +3 -2
- data/src/core/lib/compression/compression_internal.cc +1 -1
- data/src/core/lib/gpr/env_linux.cc +10 -21
- data/src/core/lib/gpr/env_posix.cc +0 -5
- data/src/core/lib/gpr/string.cc +7 -2
- data/src/core/lib/gpr/string.h +1 -0
- data/src/core/lib/gpr/sync_posix.cc +0 -129
- data/src/core/lib/gprpp/debug_location.h +3 -2
- data/src/core/lib/gprpp/fork.cc +14 -21
- data/src/core/lib/gprpp/fork.h +15 -4
- data/src/core/lib/gprpp/host_port.cc +118 -0
- data/src/core/lib/{gpr → gprpp}/host_port.h +27 -11
- data/src/core/lib/gprpp/map.h +25 -0
- data/src/core/lib/gprpp/memory.h +26 -9
- data/src/core/lib/gprpp/ref_counted.h +63 -21
- data/src/core/lib/gprpp/string_view.h +143 -0
- data/src/core/lib/gprpp/thd.h +10 -1
- data/src/core/lib/gprpp/thd_posix.cc +25 -0
- data/src/core/lib/gprpp/thd_windows.cc +9 -1
- data/src/core/lib/http/httpcli_security_connector.cc +3 -1
- data/src/core/lib/iomgr/cfstream_handle.cc +6 -1
- data/src/core/lib/iomgr/cfstream_handle.h +8 -2
- data/src/core/lib/iomgr/combiner.cc +4 -4
- data/src/core/lib/iomgr/error.cc +18 -8
- data/src/core/lib/iomgr/error.h +2 -0
- data/src/core/lib/iomgr/ev_posix.cc +4 -2
- data/src/core/lib/iomgr/executor.cc +4 -1
- data/src/core/lib/iomgr/executor/mpmcqueue.cc +183 -0
- data/src/core/lib/iomgr/executor/mpmcqueue.h +178 -0
- data/src/core/lib/iomgr/executor/threadpool.cc +138 -0
- data/src/core/lib/iomgr/executor/threadpool.h +153 -0
- data/src/core/lib/iomgr/fork_posix.cc +4 -2
- data/src/core/lib/iomgr/iocp_windows.cc +2 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +14 -0
- data/src/core/lib/iomgr/iomgr_uv.cc +3 -0
- data/src/core/lib/iomgr/lockfree_event.cc +3 -3
- data/src/core/lib/iomgr/resolve_address_custom.cc +16 -20
- data/src/core/lib/iomgr/resolve_address_posix.cc +8 -10
- data/src/core/lib/iomgr/resolve_address_windows.cc +6 -8
- data/src/core/lib/iomgr/sockaddr_utils.cc +5 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +0 -1
- data/src/core/lib/iomgr/socket_windows.h +1 -1
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +7 -6
- data/src/core/lib/iomgr/tcp_client_custom.cc +1 -0
- data/src/core/lib/iomgr/tcp_custom.cc +4 -0
- data/src/core/lib/iomgr/tcp_posix.cc +8 -2
- data/src/core/lib/iomgr/tcp_server_custom.cc +1 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
- data/src/core/lib/iomgr/tcp_windows.cc +7 -7
- data/src/core/lib/iomgr/timer_custom.cc +1 -0
- data/src/core/lib/iomgr/timer_manager.cc +0 -29
- data/src/core/lib/security/credentials/credentials.cc +84 -0
- data/src/core/lib/security/credentials/credentials.h +58 -2
- data/src/core/lib/security/credentials/jwt/json_token.cc +6 -2
- data/src/core/lib/security/credentials/jwt/json_token.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +245 -24
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +16 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +3 -2
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +21 -25
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +3 -2
- data/src/core/lib/security/security_connector/security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/security_connector.h +1 -1
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +19 -19
- data/src/core/lib/security/security_connector/ssl_utils.cc +26 -31
- data/src/core/lib/security/security_connector/ssl_utils.h +11 -8
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +16 -20
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +4 -3
- data/src/core/lib/security/transport/client_auth_filter.cc +1 -2
- data/src/core/lib/security/util/json_util.cc +19 -5
- data/src/core/lib/security/util/json_util.h +3 -1
- data/src/core/lib/slice/slice.cc +69 -50
- data/src/core/lib/slice/slice_buffer.cc +6 -5
- data/src/core/lib/slice/slice_hash_table.h +3 -7
- data/src/core/lib/slice/slice_intern.cc +130 -39
- data/src/core/lib/slice/slice_internal.h +8 -0
- data/src/core/lib/slice/slice_utils.h +120 -0
- data/src/core/lib/slice/slice_weak_hash_table.h +2 -7
- data/src/core/lib/surface/call.cc +8 -3
- data/src/core/lib/surface/channel.cc +31 -8
- data/src/core/lib/surface/completion_queue.cc +17 -7
- data/src/core/lib/surface/init_secure.cc +4 -1
- data/src/core/lib/surface/lame_client.cc +2 -2
- data/src/core/lib/surface/server.cc +34 -35
- data/src/core/lib/surface/server.h +8 -17
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/byte_stream.cc +3 -5
- data/src/core/lib/transport/byte_stream.h +1 -2
- data/src/core/lib/transport/error_utils.cc +10 -1
- data/src/core/lib/transport/metadata.cc +202 -35
- data/src/core/lib/transport/metadata.h +81 -6
- data/src/core/lib/transport/static_metadata.cc +1257 -465
- data/src/core/lib/transport/static_metadata.h +190 -347
- data/src/core/lib/transport/timeout_encoding.cc +7 -0
- data/src/core/lib/transport/timeout_encoding.h +3 -2
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +0 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +2 -7
- data/src/core/tsi/ssl_transport_security.cc +35 -43
- data/src/core/tsi/ssl_transport_security.h +2 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
- data/src/ruby/lib/grpc/grpc.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +39 -33
- data/src/core/lib/gpr/host_port.cc +0 -98
@@ -21,8 +21,15 @@
|
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
+
#include <grpc/grpc_security.h>
|
24
25
|
#include "src/core/lib/json/json.h"
|
25
26
|
#include "src/core/lib/security/credentials/credentials.h"
|
27
|
+
#include "src/core/lib/uri/uri_parser.h"
|
28
|
+
|
29
|
+
// Constants.
|
30
|
+
#define GRPC_STS_POST_MINIMAL_BODY_FORMAT_STRING \
|
31
|
+
"grant_type=urn:ietf:params:oauth:grant-type:token-exchange&subject_token=%" \
|
32
|
+
"s&subject_token_type=%s"
|
26
33
|
|
27
34
|
// auth_refresh_token parsing.
|
28
35
|
typedef struct {
|
@@ -115,6 +122,7 @@ class grpc_google_refresh_token_credentials final
|
|
115
122
|
|
116
123
|
private:
|
117
124
|
grpc_auth_refresh_token refresh_token_;
|
125
|
+
grpc_closure http_post_cb_closure_;
|
118
126
|
};
|
119
127
|
|
120
128
|
// Access token credentials.
|
@@ -148,4 +156,12 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
|
|
148
156
|
const struct grpc_http_response* response, grpc_mdelem* token_md,
|
149
157
|
grpc_millis* token_lifetime);
|
150
158
|
|
159
|
+
namespace grpc_core {
|
160
|
+
// Exposed for testing only. This function validates the options, ensuring that
|
161
|
+
// the required fields are set, and outputs the parsed URL of the STS token
|
162
|
+
// exchanged service.
|
163
|
+
grpc_error* ValidateStsCredentialsOptions(
|
164
|
+
const grpc_sts_credentials_options* options, grpc_uri** sts_url);
|
165
|
+
} // namespace grpc_core
|
166
|
+
|
151
167
|
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */
|
@@ -108,10 +108,11 @@ class grpc_alts_channel_security_connector final
|
|
108
108
|
return strcmp(target_name_, other->target_name_);
|
109
109
|
}
|
110
110
|
|
111
|
-
bool check_call_host(
|
111
|
+
bool check_call_host(grpc_core::StringView host,
|
112
|
+
grpc_auth_context* auth_context,
|
112
113
|
grpc_closure* on_call_host_checked,
|
113
114
|
grpc_error** error) override {
|
114
|
-
if (host
|
115
|
+
if (host.empty() || host != target_name_) {
|
115
116
|
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
116
117
|
"ALTS call host does not match target name");
|
117
118
|
}
|
@@ -31,8 +31,8 @@
|
|
31
31
|
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
|
32
32
|
#include "src/core/lib/channel/channel_args.h"
|
33
33
|
#include "src/core/lib/channel/handshaker.h"
|
34
|
-
#include "src/core/lib/gpr/host_port.h"
|
35
34
|
#include "src/core/lib/gpr/string.h"
|
35
|
+
#include "src/core/lib/gprpp/host_port.h"
|
36
36
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
37
37
|
#include "src/core/lib/security/context/security_context.h"
|
38
38
|
#include "src/core/lib/security/credentials/credentials.h"
|
@@ -102,39 +102,35 @@ class grpc_fake_channel_security_connector final
|
|
102
102
|
tsi_create_fake_handshaker(/*is_client=*/true), this));
|
103
103
|
}
|
104
104
|
|
105
|
-
bool check_call_host(
|
105
|
+
bool check_call_host(grpc_core::StringView host,
|
106
|
+
grpc_auth_context* auth_context,
|
106
107
|
grpc_closure* on_call_host_checked,
|
107
108
|
grpc_error** error) override {
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
grpc_core::StringView authority_hostname;
|
110
|
+
grpc_core::StringView authority_ignored_port;
|
111
|
+
grpc_core::StringView target_hostname;
|
112
|
+
grpc_core::StringView target_ignored_port;
|
113
|
+
grpc_core::SplitHostPort(host, &authority_hostname,
|
114
|
+
&authority_ignored_port);
|
115
|
+
grpc_core::SplitHostPort(target_, &target_hostname, &target_ignored_port);
|
114
116
|
if (target_name_override_ != nullptr) {
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
if (
|
121
|
-
fake_security_target_name_override_hostname) != 0) {
|
117
|
+
grpc_core::StringView fake_security_target_name_override_hostname;
|
118
|
+
grpc_core::StringView fake_security_target_name_override_ignored_port;
|
119
|
+
grpc_core::SplitHostPort(
|
120
|
+
target_name_override_, &fake_security_target_name_override_hostname,
|
121
|
+
&fake_security_target_name_override_ignored_port);
|
122
|
+
if (authority_hostname != fake_security_target_name_override_hostname) {
|
122
123
|
gpr_log(GPR_ERROR,
|
123
124
|
"Authority (host) '%s' != Fake Security Target override '%s'",
|
124
|
-
host,
|
125
|
+
host.data(),
|
126
|
+
fake_security_target_name_override_hostname.data());
|
125
127
|
abort();
|
126
128
|
}
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'",
|
131
|
-
authority_hostname, target_hostname);
|
129
|
+
} else if (authority_hostname != target_hostname) {
|
130
|
+
gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", host.data(),
|
131
|
+
target_);
|
132
132
|
abort();
|
133
133
|
}
|
134
|
-
gpr_free(authority_hostname);
|
135
|
-
gpr_free(authority_ignored_port);
|
136
|
-
gpr_free(target_hostname);
|
137
|
-
gpr_free(target_ignored_port);
|
138
134
|
return true;
|
139
135
|
}
|
140
136
|
|
@@ -156,10 +156,11 @@ class grpc_local_channel_security_connector final
|
|
156
156
|
creds->connect_type());
|
157
157
|
}
|
158
158
|
|
159
|
-
bool check_call_host(
|
159
|
+
bool check_call_host(grpc_core::StringView host,
|
160
|
+
grpc_auth_context* auth_context,
|
160
161
|
grpc_closure* on_call_host_checked,
|
161
162
|
grpc_error** error) override {
|
162
|
-
if (host
|
163
|
+
if (host.empty() || host != target_name_) {
|
163
164
|
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
164
165
|
"local call host does not match target name");
|
165
166
|
}
|
@@ -28,8 +28,8 @@
|
|
28
28
|
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
|
29
29
|
#include "src/core/lib/channel/channel_args.h"
|
30
30
|
#include "src/core/lib/channel/handshaker.h"
|
31
|
-
#include "src/core/lib/gpr/host_port.h"
|
32
31
|
#include "src/core/lib/gpr/string.h"
|
32
|
+
#include "src/core/lib/gprpp/host_port.h"
|
33
33
|
#include "src/core/lib/iomgr/load_file.h"
|
34
34
|
#include "src/core/lib/security/context/security_context.h"
|
35
35
|
#include "src/core/lib/security/credentials/credentials.h"
|
@@ -98,7 +98,7 @@ class grpc_channel_security_connector : public grpc_security_connector {
|
|
98
98
|
/// Returns true if completed synchronously, in which case \a error will
|
99
99
|
/// be set to indicate the result. Otherwise, \a on_call_host_checked
|
100
100
|
/// will be invoked when complete.
|
101
|
-
virtual bool check_call_host(
|
101
|
+
virtual bool check_call_host(grpc_core::StringView host,
|
102
102
|
grpc_auth_context* auth_context,
|
103
103
|
grpc_closure* on_call_host_checked,
|
104
104
|
grpc_error** error) GRPC_ABSTRACT;
|
@@ -28,8 +28,8 @@
|
|
28
28
|
|
29
29
|
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
|
30
30
|
#include "src/core/lib/channel/handshaker.h"
|
31
|
-
#include "src/core/lib/gpr/host_port.h"
|
32
31
|
#include "src/core/lib/gpr/string.h"
|
32
|
+
#include "src/core/lib/gprpp/host_port.h"
|
33
33
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
34
34
|
#include "src/core/lib/security/context/security_context.h"
|
35
35
|
#include "src/core/lib/security/credentials/credentials.h"
|
@@ -75,15 +75,14 @@ class grpc_ssl_channel_security_connector final
|
|
75
75
|
? nullptr
|
76
76
|
: gpr_strdup(overridden_target_name)),
|
77
77
|
verify_options_(&config->verify_options) {
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
grpc_core::StringView host;
|
79
|
+
grpc_core::StringView port;
|
80
|
+
grpc_core::SplitHostPort(target_name, &host, &port);
|
81
|
+
target_name_ = host.dup();
|
81
82
|
}
|
82
83
|
|
83
84
|
~grpc_ssl_channel_security_connector() override {
|
84
85
|
tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_);
|
85
|
-
if (target_name_ != nullptr) gpr_free(target_name_);
|
86
|
-
if (overridden_target_name_ != nullptr) gpr_free(overridden_target_name_);
|
87
86
|
}
|
88
87
|
|
89
88
|
grpc_security_status InitializeHandshakerFactory(
|
@@ -123,8 +122,8 @@ class grpc_ssl_channel_security_connector final
|
|
123
122
|
tsi_handshaker* tsi_hs = nullptr;
|
124
123
|
tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
|
125
124
|
client_handshaker_factory_,
|
126
|
-
overridden_target_name_ != nullptr ? overridden_target_name_
|
127
|
-
: target_name_,
|
125
|
+
overridden_target_name_ != nullptr ? overridden_target_name_.get()
|
126
|
+
: target_name_.get(),
|
128
127
|
&tsi_hs);
|
129
128
|
if (result != TSI_OK) {
|
130
129
|
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
|
@@ -139,8 +138,8 @@ class grpc_ssl_channel_security_connector final
|
|
139
138
|
grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
|
140
139
|
grpc_closure* on_peer_checked) override {
|
141
140
|
const char* target_name = overridden_target_name_ != nullptr
|
142
|
-
? overridden_target_name_
|
143
|
-
: target_name_;
|
141
|
+
? overridden_target_name_.get()
|
142
|
+
: target_name_.get();
|
144
143
|
grpc_error* error = ssl_check_peer(target_name, &peer, auth_context);
|
145
144
|
if (error == GRPC_ERROR_NONE &&
|
146
145
|
verify_options_->verify_peer_callback != nullptr) {
|
@@ -175,17 +174,18 @@ class grpc_ssl_channel_security_connector final
|
|
175
174
|
reinterpret_cast<const grpc_ssl_channel_security_connector*>(other_sc);
|
176
175
|
int c = channel_security_connector_cmp(other);
|
177
176
|
if (c != 0) return c;
|
178
|
-
c = strcmp(target_name_, other->target_name_);
|
177
|
+
c = strcmp(target_name_.get(), other->target_name_.get());
|
179
178
|
if (c != 0) return c;
|
180
179
|
return (overridden_target_name_ == nullptr ||
|
181
180
|
other->overridden_target_name_ == nullptr)
|
182
|
-
? GPR_ICMP(overridden_target_name_,
|
183
|
-
other->overridden_target_name_)
|
184
|
-
: strcmp(overridden_target_name_,
|
185
|
-
other->overridden_target_name_);
|
181
|
+
? GPR_ICMP(overridden_target_name_.get(),
|
182
|
+
other->overridden_target_name_.get())
|
183
|
+
: strcmp(overridden_target_name_.get(),
|
184
|
+
other->overridden_target_name_.get());
|
186
185
|
}
|
187
186
|
|
188
|
-
bool check_call_host(
|
187
|
+
bool check_call_host(grpc_core::StringView host,
|
188
|
+
grpc_auth_context* auth_context,
|
189
189
|
grpc_closure* on_call_host_checked,
|
190
190
|
grpc_error** error) override {
|
191
191
|
grpc_security_status status = GRPC_SECURITY_ERROR;
|
@@ -194,7 +194,7 @@ class grpc_ssl_channel_security_connector final
|
|
194
194
|
/* If the target name was overridden, then the original target_name was
|
195
195
|
'checked' transitively during the previous peer check at the end of the
|
196
196
|
handshake. */
|
197
|
-
if (overridden_target_name_ != nullptr &&
|
197
|
+
if (overridden_target_name_ != nullptr && host == target_name_.get()) {
|
198
198
|
status = GRPC_SECURITY_OK;
|
199
199
|
}
|
200
200
|
if (status != GRPC_SECURITY_OK) {
|
@@ -212,8 +212,8 @@ class grpc_ssl_channel_security_connector final
|
|
212
212
|
|
213
213
|
private:
|
214
214
|
tsi_ssl_client_handshaker_factory* client_handshaker_factory_;
|
215
|
-
char
|
216
|
-
char
|
215
|
+
grpc_core::UniquePtr<char> target_name_;
|
216
|
+
grpc_core::UniquePtr<char> overridden_target_name_;
|
217
217
|
const verify_peer_options* verify_options_;
|
218
218
|
};
|
219
219
|
|
@@ -27,9 +27,9 @@
|
|
27
27
|
|
28
28
|
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
|
29
29
|
#include "src/core/lib/channel/channel_args.h"
|
30
|
-
#include "src/core/lib/gpr/host_port.h"
|
31
30
|
#include "src/core/lib/gpr/string.h"
|
32
31
|
#include "src/core/lib/gprpp/global_config.h"
|
32
|
+
#include "src/core/lib/gprpp/host_port.h"
|
33
33
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
34
34
|
#include "src/core/lib/iomgr/load_file.h"
|
35
35
|
#include "src/core/lib/security/context/security_context.h"
|
@@ -136,12 +136,13 @@ grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer) {
|
|
136
136
|
return GRPC_ERROR_NONE;
|
137
137
|
}
|
138
138
|
|
139
|
-
grpc_error* grpc_ssl_check_peer_name(
|
139
|
+
grpc_error* grpc_ssl_check_peer_name(grpc_core::StringView peer_name,
|
140
140
|
const tsi_peer* peer) {
|
141
141
|
/* Check the peer name if specified. */
|
142
|
-
if (peer_name
|
142
|
+
if (!peer_name.empty() && !grpc_ssl_host_matches_name(peer, peer_name)) {
|
143
143
|
char* msg;
|
144
|
-
gpr_asprintf(&msg, "Peer name %s is not in peer certificate",
|
144
|
+
gpr_asprintf(&msg, "Peer name %s is not in peer certificate",
|
145
|
+
peer_name.data());
|
145
146
|
grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
146
147
|
gpr_free(msg);
|
147
148
|
return error;
|
@@ -149,15 +150,16 @@ grpc_error* grpc_ssl_check_peer_name(const char* peer_name,
|
|
149
150
|
return GRPC_ERROR_NONE;
|
150
151
|
}
|
151
152
|
|
152
|
-
bool grpc_ssl_check_call_host(
|
153
|
-
|
153
|
+
bool grpc_ssl_check_call_host(grpc_core::StringView host,
|
154
|
+
grpc_core::StringView target_name,
|
155
|
+
grpc_core::StringView overridden_target_name,
|
154
156
|
grpc_auth_context* auth_context,
|
155
157
|
grpc_closure* on_call_host_checked,
|
156
158
|
grpc_error** error) {
|
157
159
|
grpc_security_status status = GRPC_SECURITY_ERROR;
|
158
160
|
tsi_peer peer = grpc_shallow_peer_from_ssl_auth_context(auth_context);
|
159
161
|
if (grpc_ssl_host_matches_name(&peer, host)) status = GRPC_SECURITY_OK;
|
160
|
-
if (overridden_target_name
|
162
|
+
if (!overridden_target_name.empty() && host == target_name) {
|
161
163
|
status = GRPC_SECURITY_OK;
|
162
164
|
}
|
163
165
|
if (status != GRPC_SECURITY_OK) {
|
@@ -179,35 +181,28 @@ const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
|
|
179
181
|
return alpn_protocol_strings;
|
180
182
|
}
|
181
183
|
|
182
|
-
int grpc_ssl_host_matches_name(const tsi_peer* peer,
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
gpr_free(ignored_port);
|
189
|
-
peer_name = allocated_name;
|
190
|
-
if (!peer_name) return 0;
|
184
|
+
int grpc_ssl_host_matches_name(const tsi_peer* peer,
|
185
|
+
grpc_core::StringView peer_name) {
|
186
|
+
grpc_core::StringView allocated_name;
|
187
|
+
grpc_core::StringView ignored_port;
|
188
|
+
grpc_core::SplitHostPort(peer_name, &allocated_name, &ignored_port);
|
189
|
+
if (allocated_name.empty()) return 0;
|
191
190
|
|
192
191
|
// IPv6 zone-id should not be included in comparisons.
|
193
|
-
|
194
|
-
if (zone_id !=
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
return r;
|
192
|
+
const size_t zone_id = allocated_name.find('%');
|
193
|
+
if (zone_id != grpc_core::StringView::npos) {
|
194
|
+
allocated_name.remove_suffix(allocated_name.size() - zone_id);
|
195
|
+
}
|
196
|
+
return tsi_ssl_peer_matches_name(peer, allocated_name);
|
199
197
|
}
|
200
198
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
int c =
|
199
|
+
int grpc_ssl_cmp_target_name(
|
200
|
+
grpc_core::StringView target_name, grpc_core::StringView other_target_name,
|
201
|
+
grpc_core::StringView overridden_target_name,
|
202
|
+
grpc_core::StringView other_overridden_target_name) {
|
203
|
+
int c = target_name.cmp(other_target_name);
|
206
204
|
if (c != 0) return c;
|
207
|
-
return (
|
208
|
-
other_overridden_target_name == nullptr)
|
209
|
-
? GPR_ICMP(overridden_target_name, other_overridden_target_name)
|
210
|
-
: strcmp(overridden_target_name, other_overridden_target_name);
|
205
|
+
return overridden_target_name.cmp(other_overridden_target_name);
|
211
206
|
}
|
212
207
|
|
213
208
|
grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
|
@@ -28,6 +28,7 @@
|
|
28
28
|
|
29
29
|
#include "src/core/lib/gprpp/global_config.h"
|
30
30
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
31
|
+
#include "src/core/lib/gprpp/string_view.h"
|
31
32
|
#include "src/core/lib/iomgr/error.h"
|
32
33
|
#include "src/core/lib/security/security_connector/security_connector.h"
|
33
34
|
#include "src/core/tsi/ssl_transport_security.h"
|
@@ -46,16 +47,17 @@ GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots);
|
|
46
47
|
grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer);
|
47
48
|
|
48
49
|
/* Check peer name information returned from SSL handshakes. */
|
49
|
-
grpc_error* grpc_ssl_check_peer_name(
|
50
|
+
grpc_error* grpc_ssl_check_peer_name(grpc_core::StringView peer_name,
|
50
51
|
const tsi_peer* peer);
|
51
52
|
/* Compare targer_name information extracted from SSL security connectors. */
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
int grpc_ssl_cmp_target_name(
|
54
|
+
grpc_core::StringView target_name, grpc_core::StringView other_target_name,
|
55
|
+
grpc_core::StringView overridden_target_name,
|
56
|
+
grpc_core::StringView other_overridden_target_name);
|
56
57
|
/* Check the host that will be set for a call is acceptable.*/
|
57
|
-
bool grpc_ssl_check_call_host(
|
58
|
-
|
58
|
+
bool grpc_ssl_check_call_host(grpc_core::StringView host,
|
59
|
+
grpc_core::StringView target_name,
|
60
|
+
grpc_core::StringView overridden_target_name,
|
59
61
|
grpc_auth_context* auth_context,
|
60
62
|
grpc_closure* on_call_host_checked,
|
61
63
|
grpc_error** error);
|
@@ -89,7 +91,8 @@ grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
|
|
89
91
|
tsi_peer grpc_shallow_peer_from_ssl_auth_context(
|
90
92
|
const grpc_auth_context* auth_context);
|
91
93
|
void grpc_shallow_peer_destruct(tsi_peer* peer);
|
92
|
-
int grpc_ssl_host_matches_name(const tsi_peer* peer,
|
94
|
+
int grpc_ssl_host_matches_name(const tsi_peer* peer,
|
95
|
+
grpc_core::StringView peer_name);
|
93
96
|
|
94
97
|
/* --- Default SSL Root Store. --- */
|
95
98
|
namespace grpc_core {
|
@@ -28,7 +28,7 @@
|
|
28
28
|
#include <grpc/support/log.h>
|
29
29
|
#include <grpc/support/string_util.h>
|
30
30
|
|
31
|
-
#include "src/core/lib/
|
31
|
+
#include "src/core/lib/gprpp/host_port.h"
|
32
32
|
#include "src/core/lib/security/credentials/ssl/ssl_credentials.h"
|
33
33
|
#include "src/core/lib/security/credentials/tls/spiffe_credentials.h"
|
34
34
|
#include "src/core/lib/security/security_connector/ssl_utils.h"
|
@@ -105,18 +105,13 @@ SpiffeChannelSecurityConnector::SpiffeChannelSecurityConnector(
|
|
105
105
|
? nullptr
|
106
106
|
: gpr_strdup(overridden_target_name)) {
|
107
107
|
check_arg_ = ServerAuthorizationCheckArgCreate(this);
|
108
|
-
|
109
|
-
|
110
|
-
|
108
|
+
grpc_core::StringView host;
|
109
|
+
grpc_core::StringView port;
|
110
|
+
grpc_core::SplitHostPort(target_name, &host, &port);
|
111
|
+
target_name_ = host.dup();
|
111
112
|
}
|
112
113
|
|
113
114
|
SpiffeChannelSecurityConnector::~SpiffeChannelSecurityConnector() {
|
114
|
-
if (target_name_ != nullptr) {
|
115
|
-
gpr_free(target_name_);
|
116
|
-
}
|
117
|
-
if (overridden_target_name_ != nullptr) {
|
118
|
-
gpr_free(overridden_target_name_);
|
119
|
-
}
|
120
115
|
if (client_handshaker_factory_ != nullptr) {
|
121
116
|
tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_);
|
122
117
|
}
|
@@ -130,8 +125,8 @@ void SpiffeChannelSecurityConnector::add_handshakers(
|
|
130
125
|
tsi_handshaker* tsi_hs = nullptr;
|
131
126
|
tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
|
132
127
|
client_handshaker_factory_,
|
133
|
-
overridden_target_name_ != nullptr ? overridden_target_name_
|
134
|
-
: target_name_,
|
128
|
+
overridden_target_name_ != nullptr ? overridden_target_name_.get()
|
129
|
+
: target_name_.get(),
|
135
130
|
&tsi_hs);
|
136
131
|
if (result != TSI_OK) {
|
137
132
|
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
|
@@ -147,8 +142,8 @@ void SpiffeChannelSecurityConnector::check_peer(
|
|
147
142
|
grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
|
148
143
|
grpc_closure* on_peer_checked) {
|
149
144
|
const char* target_name = overridden_target_name_ != nullptr
|
150
|
-
? overridden_target_name_
|
151
|
-
: target_name_;
|
145
|
+
? overridden_target_name_.get()
|
146
|
+
: target_name_.get();
|
152
147
|
grpc_error* error = grpc_ssl_check_alpn(&peer);
|
153
148
|
if (error != GRPC_ERROR_NONE) {
|
154
149
|
GRPC_CLOSURE_SCHED(on_peer_checked, error);
|
@@ -203,16 +198,17 @@ int SpiffeChannelSecurityConnector::cmp(
|
|
203
198
|
if (c != 0) {
|
204
199
|
return c;
|
205
200
|
}
|
206
|
-
return grpc_ssl_cmp_target_name(target_name_, other->target_name_,
|
207
|
-
overridden_target_name_,
|
208
|
-
other->overridden_target_name_);
|
201
|
+
return grpc_ssl_cmp_target_name(target_name_.get(), other->target_name_.get(),
|
202
|
+
overridden_target_name_.get(),
|
203
|
+
other->overridden_target_name_.get());
|
209
204
|
}
|
210
205
|
|
211
206
|
bool SpiffeChannelSecurityConnector::check_call_host(
|
212
|
-
|
207
|
+
grpc_core::StringView host, grpc_auth_context* auth_context,
|
213
208
|
grpc_closure* on_call_host_checked, grpc_error** error) {
|
214
|
-
return grpc_ssl_check_call_host(host, target_name_,
|
215
|
-
|
209
|
+
return grpc_ssl_check_call_host(host, target_name_.get(),
|
210
|
+
overridden_target_name_.get(), auth_context,
|
211
|
+
on_call_host_checked, error);
|
216
212
|
}
|
217
213
|
|
218
214
|
void SpiffeChannelSecurityConnector::cancel_check_call_host(
|