grpc 1.3.4 → 1.4.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 +581 -450
- data/include/grpc/census.h +49 -49
- data/include/grpc/grpc.h +16 -70
- data/include/grpc/grpc_security.h +59 -59
- data/include/grpc/grpc_security_constants.h +9 -9
- data/include/grpc/impl/codegen/atm.h +1 -1
- data/include/grpc/impl/codegen/atm_windows.h +4 -4
- data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -2
- data/include/grpc/impl/codegen/compression_types.h +4 -5
- data/include/grpc/impl/codegen/gpr_slice.h +5 -5
- data/include/grpc/impl/codegen/gpr_types.h +6 -7
- data/include/grpc/impl/codegen/grpc_types.h +128 -59
- data/include/grpc/impl/codegen/port_platform.h +6 -0
- data/include/grpc/impl/codegen/propagation_bits.h +2 -2
- data/include/grpc/impl/codegen/slice.h +13 -12
- data/include/grpc/impl/codegen/status.h +23 -18
- data/include/grpc/impl/codegen/sync.h +1 -1
- data/include/grpc/load_reporting.h +6 -6
- data/include/grpc/slice.h +47 -25
- data/include/grpc/slice_buffer.h +18 -14
- data/include/grpc/support/alloc.h +7 -7
- data/include/grpc/support/cmdline.h +10 -10
- data/include/grpc/support/cpu.h +3 -3
- data/include/grpc/support/histogram.h +1 -1
- data/include/grpc/support/host_port.h +2 -2
- data/include/grpc/support/log.h +9 -9
- data/include/grpc/support/log_windows.h +1 -1
- data/include/grpc/support/string_util.h +3 -3
- data/include/grpc/support/subprocess.h +3 -3
- data/include/grpc/support/sync.h +31 -31
- data/include/grpc/support/thd.h +11 -11
- data/include/grpc/support/time.h +12 -12
- data/include/grpc/support/tls.h +1 -1
- data/include/grpc/support/tls_gcc.h +2 -2
- data/include/grpc/support/tls_msvc.h +1 -1
- data/include/grpc/support/tls_pthread.h +1 -1
- data/include/grpc/support/useful.h +2 -2
- data/include/grpc/support/workaround_list.h +46 -0
- data/src/core/ext/census/context.c +1 -1
- data/src/core/ext/census/intrusive_hash_map.c +319 -0
- data/src/core/ext/census/intrusive_hash_map.h +167 -0
- data/src/core/ext/census/intrusive_hash_map_internal.h +63 -0
- data/src/core/ext/census/resource.c +3 -1
- data/src/core/ext/filters/client_channel/channel_connectivity.c +1 -1
- data/src/core/ext/filters/client_channel/client_channel.c +173 -103
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +3 -2
- data/src/core/ext/filters/client_channel/lb_policy.c +2 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +8 -7
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +153 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +42 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +405 -102
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +133 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +65 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +90 -51
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +7 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +19 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +63 -34
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +188 -294
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +28 -5
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +18 -4
- data/src/core/ext/filters/client_channel/parse_address.c +90 -59
- data/src/core/ext/filters/client_channel/parse_address.h +17 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +11 -7
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +59 -14
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +6 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +3 -3
- data/src/core/ext/filters/client_channel/subchannel.c +20 -17
- data/src/core/ext/filters/client_channel/subchannel.h +1 -0
- data/src/core/ext/filters/client_channel/subchannel_index.c +11 -1
- data/src/core/ext/filters/client_channel/uri_parser.c +36 -22
- data/src/core/ext/filters/client_channel/uri_parser.h +1 -1
- data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.c +42 -17
- data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.h +8 -9
- data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.c +19 -11
- data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.h +3 -6
- data/src/core/ext/filters/http/http_filters_plugin.c +104 -0
- data/src/core/{lib/channel/compress_filter.c → ext/filters/http/message_compress/message_compress_filter.c} +124 -23
- data/src/core/{lib/channel/compress_filter.h → ext/filters/http/message_compress/message_compress_filter.h} +5 -6
- data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.c +4 -6
- data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.h +3 -3
- data/src/core/ext/filters/load_reporting/load_reporting.c +2 -25
- data/src/core/ext/filters/load_reporting/load_reporting_filter.c +26 -1
- data/src/core/ext/filters/max_age/max_age_filter.c +14 -14
- data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.c +91 -47
- data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.h +3 -3
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +223 -0
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +40 -0
- data/src/core/ext/filters/workarounds/workaround_utils.c +65 -0
- data/src/core/ext/filters/workarounds/workaround_utils.h +52 -0
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +3 -2
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +2 -2
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +3 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +319 -175
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_data.c +203 -164
- data/src/core/ext/transport/chttp2/transport/frame_data.h +8 -14
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +5 -5
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +4 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +2 -4
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +4 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +50 -33
- data/src/core/ext/transport/chttp2/transport/parsing.c +10 -11
- data/src/core/ext/transport/chttp2/transport/writing.c +32 -13
- data/src/core/lib/channel/channel_args.c +30 -9
- data/src/core/lib/channel/channel_args.h +5 -1
- data/src/core/lib/channel/channel_stack.c +1 -1
- data/src/core/lib/channel/channel_stack.h +2 -2
- data/src/core/lib/channel/channel_stack_builder.c +13 -1
- data/src/core/lib/channel/channel_stack_builder.h +5 -1
- data/src/core/lib/channel/connected_channel.c +3 -1
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/compression/message_compress.c +2 -2
- data/src/core/lib/debug/trace.c +13 -6
- data/src/core/lib/debug/trace.h +27 -1
- data/src/core/lib/http/httpcli.c +1 -1
- data/src/core/lib/http/httpcli_security_connector.c +9 -11
- data/src/core/lib/http/parser.c +2 -2
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/combiner.c +6 -6
- data/src/core/lib/iomgr/combiner.h +2 -1
- data/src/core/lib/iomgr/error.c +12 -5
- data/src/core/lib/iomgr/error.h +13 -13
- data/src/core/lib/iomgr/ev_epoll1_linux.c +984 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.h +44 -0
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +2146 -0
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +43 -0
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +1337 -0
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +43 -0
- data/src/core/lib/iomgr/ev_epollex_linux.c +1511 -0
- data/src/core/lib/iomgr/ev_epollex_linux.h +43 -0
- data/src/core/lib/iomgr/{ev_epoll_linux.c → ev_epollsig_linux.c} +41 -33
- data/src/core/lib/iomgr/{ev_epoll_linux.h → ev_epollsig_linux.h} +4 -4
- data/src/core/lib/iomgr/ev_poll_posix.c +12 -27
- data/src/core/lib/iomgr/ev_poll_posix.h +2 -2
- data/src/core/lib/iomgr/ev_posix.c +22 -8
- data/src/core/lib/iomgr/ev_posix.h +4 -3
- data/src/core/lib/iomgr/ev_windows.c +43 -0
- data/src/core/lib/iomgr/exec_ctx.c +5 -0
- data/src/core/lib/iomgr/exec_ctx.h +2 -0
- data/src/core/lib/iomgr/iomgr.c +4 -0
- data/src/core/lib/iomgr/iomgr.h +3 -0
- data/src/core/lib/iomgr/is_epollexclusive_available.c +116 -0
- data/src/core/lib/iomgr/is_epollexclusive_available.h +41 -0
- data/src/core/lib/iomgr/lockfree_event.c +16 -0
- data/src/core/lib/iomgr/pollset.h +2 -5
- data/src/core/lib/iomgr/pollset_uv.c +1 -1
- data/src/core/lib/iomgr/pollset_windows.c +3 -3
- data/src/core/lib/iomgr/resource_quota.c +9 -8
- data/src/core/lib/iomgr/resource_quota.h +2 -1
- data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
- data/src/core/lib/iomgr/socket_mutator.h +2 -0
- data/src/core/lib/iomgr/sys_epoll_wrapper.h +43 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +6 -6
- data/src/core/lib/iomgr/tcp_client_uv.c +3 -3
- data/src/core/lib/iomgr/tcp_posix.c +7 -7
- data/src/core/lib/iomgr/tcp_posix.h +2 -1
- data/src/core/lib/iomgr/tcp_server_posix.c +1 -1
- data/src/core/lib/iomgr/tcp_uv.c +6 -6
- data/src/core/lib/iomgr/tcp_uv.h +2 -1
- data/src/core/lib/iomgr/tcp_windows.c +1 -1
- data/src/core/lib/iomgr/timer_generic.c +24 -25
- data/src/core/lib/iomgr/timer_manager.c +276 -0
- data/src/core/lib/iomgr/timer_manager.h +52 -0
- data/src/core/lib/iomgr/timer_uv.c +6 -0
- data/src/core/lib/iomgr/udp_server.c +42 -9
- data/src/core/lib/iomgr/udp_server.h +3 -1
- data/src/core/lib/security/credentials/credentials.c +0 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.c +23 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -9
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +1 -1
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +24 -53
- data/src/core/lib/security/transport/client_auth_filter.c +9 -3
- data/src/core/lib/security/transport/secure_endpoint.c +7 -7
- data/src/core/lib/security/transport/secure_endpoint.h +1 -1
- data/src/core/lib/security/transport/security_connector.c +45 -57
- data/src/core/lib/security/transport/security_connector.h +10 -14
- data/src/core/lib/security/transport/security_handshaker.c +123 -97
- data/src/core/lib/slice/b64.c +1 -1
- data/src/core/lib/slice/percent_encoding.c +3 -3
- data/src/core/lib/slice/slice.c +66 -33
- data/src/core/lib/slice/slice_buffer.c +25 -6
- data/src/core/lib/slice/slice_hash_table.c +33 -35
- data/src/core/lib/slice/slice_hash_table.h +7 -12
- data/src/core/lib/support/atomic.h +45 -0
- data/src/core/lib/support/atomic_with_atm.h +70 -0
- data/src/core/lib/support/atomic_with_std.h +48 -0
- data/src/core/lib/support/avl.c +14 -14
- data/src/core/lib/support/cmdline.c +3 -3
- data/src/core/lib/support/histogram.c +2 -2
- data/src/core/lib/support/host_port.c +1 -1
- data/src/core/lib/support/memory.h +74 -0
- data/src/core/lib/support/mpscq.c +36 -2
- data/src/core/lib/support/mpscq.h +28 -1
- data/src/core/lib/support/stack_lockfree.c +3 -36
- data/src/core/lib/support/string.c +12 -12
- data/src/core/lib/support/string_posix.c +1 -1
- data/src/core/lib/support/subprocess_posix.c +2 -2
- data/src/core/lib/support/thd_posix.c +1 -1
- data/src/core/lib/support/time_posix.c +8 -0
- data/src/core/lib/support/tmpfile_posix.c +10 -10
- data/src/core/lib/surface/alarm.c +3 -1
- data/src/core/lib/surface/api_trace.c +2 -1
- data/src/core/lib/surface/api_trace.h +2 -2
- data/src/core/lib/surface/byte_buffer_reader.c +1 -1
- data/src/core/lib/surface/call.c +65 -22
- data/src/core/lib/surface/call.h +4 -2
- data/src/core/lib/surface/channel_init.c +2 -19
- data/src/core/lib/surface/channel_stack_type.c +18 -0
- data/src/core/lib/surface/channel_stack_type.h +2 -0
- data/src/core/lib/surface/completion_queue.c +694 -247
- data/src/core/lib/surface/completion_queue.h +30 -13
- data/src/core/lib/surface/completion_queue_factory.c +24 -9
- data/src/core/lib/surface/init.c +1 -52
- data/src/core/lib/surface/{lame_client.c → lame_client.cc} +37 -26
- data/src/core/lib/surface/server.c +79 -110
- data/src/core/lib/surface/server.h +2 -1
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.c +25 -9
- data/src/core/lib/transport/bdp_estimator.h +7 -1
- data/src/core/lib/transport/byte_stream.c +23 -9
- data/src/core/lib/transport/byte_stream.h +15 -6
- data/src/core/lib/transport/connectivity_state.c +6 -6
- data/src/core/lib/transport/connectivity_state.h +2 -1
- data/src/core/lib/transport/service_config.c +6 -13
- data/src/core/lib/transport/service_config.h +2 -2
- data/src/core/lib/transport/static_metadata.c +403 -389
- data/src/core/lib/transport/static_metadata.h +127 -114
- data/src/core/plugin_registry/grpc_plugin_registry.c +16 -0
- data/src/core/tsi/fake_transport_security.c +5 -4
- data/src/core/tsi/ssl_transport_security.c +71 -82
- data/src/core/tsi/ssl_transport_security.h +39 -61
- data/src/core/tsi/transport_security.c +83 -2
- data/src/core/tsi/transport_security.h +27 -2
- data/src/core/tsi/transport_security_adapter.c +236 -0
- data/src/core/tsi/transport_security_adapter.h +62 -0
- data/src/core/tsi/transport_security_interface.h +179 -66
- data/src/ruby/ext/grpc/extconf.rb +2 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +8 -6
- data/src/ruby/ext/grpc/rb_call.c +56 -48
- data/src/ruby/ext/grpc/rb_call.h +3 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +23 -22
- data/src/ruby/ext/grpc/rb_channel.c +2 -3
- data/src/ruby/ext/grpc/rb_channel_args.c +11 -9
- data/src/ruby/ext/grpc/rb_channel_credentials.c +16 -12
- data/src/ruby/ext/grpc/rb_completion_queue.c +7 -9
- data/src/ruby/ext/grpc/rb_compression_options.c +7 -6
- data/src/ruby/ext/grpc/rb_event_thread.c +10 -12
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -2
- data/src/ruby/ext/grpc/rb_grpc.c +11 -15
- data/src/ruby/ext/grpc/rb_grpc.h +2 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +25 -10
- data/src/ruby/ext/grpc/rb_server.c +26 -28
- data/src/ruby/lib/grpc/grpc.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/cares/config_linux/ares_config.h +36 -2
- data/third_party/zlib/adler32.c +14 -7
- data/third_party/zlib/compress.c +24 -18
- data/third_party/zlib/crc32.c +29 -12
- data/third_party/zlib/deflate.c +499 -303
- data/third_party/zlib/deflate.h +19 -16
- data/third_party/zlib/gzguts.h +16 -7
- data/third_party/zlib/gzlib.c +17 -14
- data/third_party/zlib/gzread.c +108 -48
- data/third_party/zlib/gzwrite.c +210 -122
- data/third_party/zlib/infback.c +2 -2
- data/third_party/zlib/inffast.c +34 -51
- data/third_party/zlib/inflate.c +86 -37
- data/third_party/zlib/inflate.h +7 -4
- data/third_party/zlib/inftrees.c +12 -14
- data/third_party/zlib/trees.c +38 -61
- data/third_party/zlib/uncompr.c +66 -32
- data/third_party/zlib/zconf.h +32 -9
- data/third_party/zlib/zlib.h +298 -154
- data/third_party/zlib/zutil.c +25 -24
- data/third_party/zlib/zutil.h +35 -17
- metadata +63 -30
@@ -39,11 +39,15 @@
|
|
39
39
|
#include <grpc/support/log.h>
|
40
40
|
#include <grpc/support/string_util.h>
|
41
41
|
|
42
|
+
#include "src/core/lib/channel/channel_args.h"
|
42
43
|
#include "src/core/lib/iomgr/executor.h"
|
43
44
|
#include "src/core/lib/support/string.h"
|
44
45
|
|
45
46
|
/* -- Fake transport security credentials. -- */
|
46
47
|
|
48
|
+
#define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \
|
49
|
+
"grpc.fake_security.expected_targets"
|
50
|
+
|
47
51
|
static grpc_security_status fake_transport_security_create_security_connector(
|
48
52
|
grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c,
|
49
53
|
grpc_call_credentials *call_creds, const char *target,
|
@@ -88,6 +92,25 @@ grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
|
|
88
92
|
return c;
|
89
93
|
}
|
90
94
|
|
95
|
+
grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets) {
|
96
|
+
grpc_arg arg;
|
97
|
+
arg.type = GRPC_ARG_STRING;
|
98
|
+
arg.key = GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS;
|
99
|
+
arg.value.string = expected_targets;
|
100
|
+
return arg;
|
101
|
+
}
|
102
|
+
|
103
|
+
const char *grpc_fake_transport_get_expected_targets(
|
104
|
+
const grpc_channel_args *args) {
|
105
|
+
const grpc_arg *expected_target_arg =
|
106
|
+
grpc_channel_args_find(args, GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS);
|
107
|
+
if (expected_target_arg != NULL &&
|
108
|
+
expected_target_arg->type == GRPC_ARG_STRING) {
|
109
|
+
return expected_target_arg->value.string;
|
110
|
+
}
|
111
|
+
return NULL;
|
112
|
+
}
|
113
|
+
|
91
114
|
/* -- Metadata-only test credentials. -- */
|
92
115
|
|
93
116
|
static void md_only_test_destruct(grpc_exec_ctx *exec_ctx,
|
@@ -38,10 +38,17 @@
|
|
38
38
|
|
39
39
|
/* -- Fake transport security credentials. -- */
|
40
40
|
|
41
|
+
/* Creates a fake transport security credentials object for testing. */
|
42
|
+
grpc_channel_credentials *grpc_fake_transport_security_credentials_create(void);
|
43
|
+
|
44
|
+
/* Creates a fake server transport security credentials object for testing. */
|
45
|
+
grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
|
46
|
+
void);
|
47
|
+
|
41
48
|
/* Used to verify the target names given to the fake transport security
|
42
49
|
* connector.
|
43
50
|
*
|
44
|
-
*
|
51
|
+
* The syntax of \a expected_targets by example:
|
45
52
|
* For LB channels:
|
46
53
|
* "backend_target_1,backend_target_2,...;lb_target_1,lb_target_2,..."
|
47
54
|
* For regular channels:
|
@@ -50,15 +57,11 @@
|
|
50
57
|
* That is to say, LB channels have a heading list of LB targets separated from
|
51
58
|
* the list of backend targets by a semicolon. For non-LB channels, only the
|
52
59
|
* latter is present. */
|
53
|
-
|
54
|
-
"grpc.test_only.fake_security.expected_target"
|
60
|
+
grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets);
|
55
61
|
|
56
|
-
/*
|
57
|
-
|
58
|
-
|
59
|
-
/* Creates a fake server transport security credentials object for testing. */
|
60
|
-
grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
|
61
|
-
void);
|
62
|
+
/* Return the value associated with the expected targets channel arg or NULL */
|
63
|
+
const char *grpc_fake_transport_get_expected_targets(
|
64
|
+
const grpc_channel_args *args);
|
62
65
|
|
63
66
|
/* -- Metadata-only Test credentials. -- */
|
64
67
|
|
@@ -99,7 +99,7 @@ static void on_compute_engine_detection_http_response(grpc_exec_ctx *exec_ctx,
|
|
99
99
|
}
|
100
100
|
|
101
101
|
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, grpc_error *e) {
|
102
|
-
grpc_pollset_destroy(p);
|
102
|
+
grpc_pollset_destroy(exec_ctx, p);
|
103
103
|
}
|
104
104
|
|
105
105
|
static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
|
@@ -171,7 +171,7 @@ static char *redact_private_key(const char *json_key) {
|
|
171
171
|
|
172
172
|
grpc_call_credentials *grpc_service_account_jwt_access_credentials_create(
|
173
173
|
const char *json_key, gpr_timespec token_lifetime, void *reserved) {
|
174
|
-
if (grpc_api_trace) {
|
174
|
+
if (GRPC_TRACER_ON(grpc_api_trace)) {
|
175
175
|
char *clean_json = redact_private_key(json_key);
|
176
176
|
gpr_log(GPR_INFO,
|
177
177
|
"grpc_service_account_jwt_access_credentials_create("
|
@@ -412,7 +412,7 @@ grpc_call_credentials *grpc_google_refresh_token_credentials_create(
|
|
412
412
|
const char *json_refresh_token, void *reserved) {
|
413
413
|
grpc_auth_refresh_token token =
|
414
414
|
grpc_auth_refresh_token_create_from_string(json_refresh_token);
|
415
|
-
if (grpc_api_trace) {
|
415
|
+
if (GRPC_TRACER_ON(grpc_api_trace)) {
|
416
416
|
char *loggable_token = create_loggable_refresh_token(&token);
|
417
417
|
gpr_log(GPR_INFO,
|
418
418
|
"grpc_refresh_token_credentials_create(json_refresh_token=%s, "
|
@@ -36,33 +36,28 @@
|
|
36
36
|
#include <string.h>
|
37
37
|
|
38
38
|
#include "src/core/lib/channel/channel_args.h"
|
39
|
-
#include "src/core/lib/channel/http_client_filter.h"
|
40
39
|
#include "src/core/lib/surface/api_trace.h"
|
41
40
|
|
42
41
|
#include <grpc/support/alloc.h>
|
43
42
|
#include <grpc/support/log.h>
|
43
|
+
#include <grpc/support/string_util.h>
|
44
44
|
|
45
45
|
//
|
46
|
-
//
|
46
|
+
// SSL Channel Credentials.
|
47
47
|
//
|
48
48
|
|
49
|
-
static void
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
static void ssl_config_pem_key_cert_pair_destroy(
|
50
|
+
tsi_ssl_pem_key_cert_pair *kp) {
|
51
|
+
if (kp == NULL) return;
|
52
|
+
gpr_free((void *)kp->private_key);
|
53
|
+
gpr_free((void *)kp->cert_chain);
|
54
54
|
}
|
55
55
|
|
56
|
-
//
|
57
|
-
// SSL Channel Credentials.
|
58
|
-
//
|
59
|
-
|
60
56
|
static void ssl_destruct(grpc_exec_ctx *exec_ctx,
|
61
57
|
grpc_channel_credentials *creds) {
|
62
58
|
grpc_ssl_credentials *c = (grpc_ssl_credentials *)creds;
|
63
|
-
|
64
|
-
|
65
|
-
if (c->config.pem_cert_chain != NULL) gpr_free(c->config.pem_cert_chain);
|
59
|
+
gpr_free(c->config.pem_root_certs);
|
60
|
+
ssl_config_pem_key_cert_pair_destroy(&c->config.pem_key_cert_pair);
|
66
61
|
}
|
67
62
|
|
68
63
|
static grpc_security_status ssl_create_security_connector(
|
@@ -103,18 +98,15 @@ static void ssl_build_config(const char *pem_root_certs,
|
|
103
98
|
grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
|
104
99
|
grpc_ssl_config *config) {
|
105
100
|
if (pem_root_certs != NULL) {
|
106
|
-
|
107
|
-
&config->pem_root_certs_size);
|
101
|
+
config->pem_root_certs = gpr_strdup(pem_root_certs);
|
108
102
|
}
|
109
103
|
if (pem_key_cert_pair != NULL) {
|
110
104
|
GPR_ASSERT(pem_key_cert_pair->private_key != NULL);
|
111
105
|
GPR_ASSERT(pem_key_cert_pair->cert_chain != NULL);
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
&config->pem_cert_chain,
|
117
|
-
&config->pem_cert_chain_size);
|
106
|
+
config->pem_key_cert_pair.cert_chain =
|
107
|
+
gpr_strdup(pem_key_cert_pair->cert_chain);
|
108
|
+
config->pem_key_cert_pair.private_key =
|
109
|
+
gpr_strdup(pem_key_cert_pair->private_key);
|
118
110
|
}
|
119
111
|
}
|
120
112
|
|
@@ -144,22 +136,10 @@ static void ssl_server_destruct(grpc_exec_ctx *exec_ctx,
|
|
144
136
|
grpc_ssl_server_credentials *c = (grpc_ssl_server_credentials *)creds;
|
145
137
|
size_t i;
|
146
138
|
for (i = 0; i < c->config.num_key_cert_pairs; i++) {
|
147
|
-
|
148
|
-
gpr_free(c->config.pem_private_keys[i]);
|
149
|
-
}
|
150
|
-
if (c->config.pem_cert_chains[i] != NULL) {
|
151
|
-
gpr_free(c->config.pem_cert_chains[i]);
|
152
|
-
}
|
153
|
-
}
|
154
|
-
if (c->config.pem_private_keys != NULL) gpr_free(c->config.pem_private_keys);
|
155
|
-
if (c->config.pem_private_keys_sizes != NULL) {
|
156
|
-
gpr_free(c->config.pem_private_keys_sizes);
|
157
|
-
}
|
158
|
-
if (c->config.pem_cert_chains != NULL) gpr_free(c->config.pem_cert_chains);
|
159
|
-
if (c->config.pem_cert_chains_sizes != NULL) {
|
160
|
-
gpr_free(c->config.pem_cert_chains_sizes);
|
139
|
+
ssl_config_pem_key_cert_pair_destroy(&c->config.pem_key_cert_pairs[i]);
|
161
140
|
}
|
162
|
-
|
141
|
+
gpr_free(c->config.pem_key_cert_pairs);
|
142
|
+
gpr_free(c->config.pem_root_certs);
|
163
143
|
}
|
164
144
|
|
165
145
|
static grpc_security_status ssl_server_create_security_connector(
|
@@ -180,30 +160,21 @@ static void ssl_build_server_config(
|
|
180
160
|
size_t i;
|
181
161
|
config->client_certificate_request = client_certificate_request;
|
182
162
|
if (pem_root_certs != NULL) {
|
183
|
-
|
184
|
-
&config->pem_root_certs_size);
|
163
|
+
config->pem_root_certs = gpr_strdup(pem_root_certs);
|
185
164
|
}
|
186
165
|
if (num_key_cert_pairs > 0) {
|
187
166
|
GPR_ASSERT(pem_key_cert_pairs != NULL);
|
188
|
-
config->
|
189
|
-
|
190
|
-
config->pem_cert_chains =
|
191
|
-
gpr_malloc(num_key_cert_pairs * sizeof(unsigned char *));
|
192
|
-
config->pem_private_keys_sizes =
|
193
|
-
gpr_malloc(num_key_cert_pairs * sizeof(size_t));
|
194
|
-
config->pem_cert_chains_sizes =
|
195
|
-
gpr_malloc(num_key_cert_pairs * sizeof(size_t));
|
167
|
+
config->pem_key_cert_pairs =
|
168
|
+
gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair));
|
196
169
|
}
|
197
170
|
config->num_key_cert_pairs = num_key_cert_pairs;
|
198
171
|
for (i = 0; i < num_key_cert_pairs; i++) {
|
199
172
|
GPR_ASSERT(pem_key_cert_pairs[i].private_key != NULL);
|
200
173
|
GPR_ASSERT(pem_key_cert_pairs[i].cert_chain != NULL);
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
&config->pem_cert_chains[i],
|
206
|
-
&config->pem_cert_chains_sizes[i]);
|
174
|
+
config->pem_key_cert_pairs[i].cert_chain =
|
175
|
+
gpr_strdup(pem_key_cert_pairs[i].cert_chain);
|
176
|
+
config->pem_key_cert_pairs[i].private_key =
|
177
|
+
gpr_strdup(pem_key_cert_pairs[i].private_key);
|
207
178
|
}
|
208
179
|
}
|
209
180
|
|
@@ -253,7 +253,7 @@ static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
|
|
253
253
|
grpc_linked_mdelem *l;
|
254
254
|
grpc_client_security_context *sec_ctx = NULL;
|
255
255
|
|
256
|
-
if (calld->security_context_set == 0
|
256
|
+
if (!op->cancel_stream && calld->security_context_set == 0) {
|
257
257
|
calld->security_context_set = 1;
|
258
258
|
GPR_ASSERT(op->payload->context != NULL);
|
259
259
|
if (op->payload->context[GRPC_CONTEXT_SECURITY].value == NULL) {
|
@@ -343,8 +343,16 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|
343
343
|
grpc_channel_element_args *args) {
|
344
344
|
grpc_security_connector *sc =
|
345
345
|
grpc_security_connector_find_in_args(args->channel_args);
|
346
|
+
if (sc == NULL) {
|
347
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
348
|
+
"Security connector missing from client auth filter args");
|
349
|
+
}
|
346
350
|
grpc_auth_context *auth_context =
|
347
351
|
grpc_find_auth_context_in_args(args->channel_args);
|
352
|
+
if (auth_context == NULL) {
|
353
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
354
|
+
"Auth context missing from client auth filter args");
|
355
|
+
}
|
348
356
|
|
349
357
|
/* grab pointers to our data from the channel element */
|
350
358
|
channel_data *chand = elem->channel_data;
|
@@ -353,8 +361,6 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|
353
361
|
handle the case that there's no 'next' filter to call on the up or down
|
354
362
|
path */
|
355
363
|
GPR_ASSERT(!args->is_last);
|
356
|
-
GPR_ASSERT(sc != NULL);
|
357
|
-
GPR_ASSERT(auth_context != NULL);
|
358
364
|
|
359
365
|
/* initialize members */
|
360
366
|
chand->security_connector =
|
@@ -75,7 +75,7 @@ typedef struct {
|
|
75
75
|
gpr_refcount ref;
|
76
76
|
} secure_endpoint;
|
77
77
|
|
78
|
-
|
78
|
+
grpc_tracer_flag grpc_trace_secure_endpoint = GRPC_TRACER_INITIALIZER(false);
|
79
79
|
|
80
80
|
static void destroy(grpc_exec_ctx *exec_ctx, secure_endpoint *secure_ep) {
|
81
81
|
secure_endpoint *ep = secure_ep;
|
@@ -130,14 +130,14 @@ static void secure_endpoint_ref(secure_endpoint *ep) { gpr_ref(&ep->ref); }
|
|
130
130
|
static void flush_read_staging_buffer(secure_endpoint *ep, uint8_t **cur,
|
131
131
|
uint8_t **end) {
|
132
132
|
grpc_slice_buffer_add(ep->read_buffer, ep->read_staging_buffer);
|
133
|
-
ep->read_staging_buffer =
|
133
|
+
ep->read_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
|
134
134
|
*cur = GRPC_SLICE_START_PTR(ep->read_staging_buffer);
|
135
135
|
*end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
|
136
136
|
}
|
137
137
|
|
138
138
|
static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep,
|
139
139
|
grpc_error *error) {
|
140
|
-
if (grpc_trace_secure_endpoint) {
|
140
|
+
if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
|
141
141
|
size_t i;
|
142
142
|
for (i = 0; i < ep->read_buffer->count; i++) {
|
143
143
|
char *data = grpc_dump_slice(ep->read_buffer->slices[i],
|
@@ -252,7 +252,7 @@ static void endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
|
|
252
252
|
static void flush_write_staging_buffer(secure_endpoint *ep, uint8_t **cur,
|
253
253
|
uint8_t **end) {
|
254
254
|
grpc_slice_buffer_add(&ep->output_buffer, ep->write_staging_buffer);
|
255
|
-
ep->write_staging_buffer =
|
255
|
+
ep->write_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
|
256
256
|
*cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer);
|
257
257
|
*end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
|
258
258
|
}
|
@@ -269,7 +269,7 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
|
|
269
269
|
|
270
270
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer);
|
271
271
|
|
272
|
-
if (grpc_trace_secure_endpoint) {
|
272
|
+
if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
|
273
273
|
for (i = 0; i < slices->count; i++) {
|
274
274
|
char *data =
|
275
275
|
grpc_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
@@ -415,8 +415,8 @@ grpc_endpoint *grpc_secure_endpoint_create(
|
|
415
415
|
grpc_slice_buffer_add(&ep->leftover_bytes,
|
416
416
|
grpc_slice_ref_internal(leftover_slices[i]));
|
417
417
|
}
|
418
|
-
ep->write_staging_buffer =
|
419
|
-
ep->read_staging_buffer =
|
418
|
+
ep->write_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
|
419
|
+
ep->read_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
|
420
420
|
grpc_slice_buffer_init(&ep->output_buffer);
|
421
421
|
grpc_slice_buffer_init(&ep->source_buffer);
|
422
422
|
ep->read_buffer = NULL;
|
@@ -39,7 +39,7 @@
|
|
39
39
|
|
40
40
|
struct tsi_frame_protector;
|
41
41
|
|
42
|
-
extern
|
42
|
+
extern grpc_tracer_flag grpc_trace_secure_endpoint;
|
43
43
|
|
44
44
|
/* Takes ownership of protector and to_wrap, and refs leftover_slices. */
|
45
45
|
grpc_endpoint *grpc_secure_endpoint_create(
|
@@ -56,6 +56,7 @@
|
|
56
56
|
#include "src/core/lib/support/string.h"
|
57
57
|
#include "src/core/tsi/fake_transport_security.h"
|
58
58
|
#include "src/core/tsi/ssl_transport_security.h"
|
59
|
+
#include "src/core/tsi/transport_security_adapter.h"
|
59
60
|
|
60
61
|
/* -- Constants. -- */
|
61
62
|
|
@@ -78,9 +79,8 @@ void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) {
|
|
78
79
|
|
79
80
|
/* Defines the cipher suites that we accept by default. All these cipher suites
|
80
81
|
are compliant with HTTP2. */
|
81
|
-
#define GRPC_SSL_CIPHER_SUITES
|
82
|
-
"ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-
|
83
|
-
"SHA384:ECDHE-RSA-AES256-GCM-SHA384"
|
82
|
+
#define GRPC_SSL_CIPHER_SUITES \
|
83
|
+
"ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384"
|
84
84
|
|
85
85
|
static gpr_once cipher_suites_once = GPR_ONCE_INIT;
|
86
86
|
static const char *cipher_suites = NULL;
|
@@ -391,7 +391,8 @@ static void fake_channel_add_handshakers(
|
|
391
391
|
grpc_handshake_manager_add(
|
392
392
|
handshake_mgr,
|
393
393
|
grpc_security_handshaker_create(
|
394
|
-
exec_ctx,
|
394
|
+
exec_ctx, tsi_create_adapter_handshaker(
|
395
|
+
tsi_create_fake_handshaker(true /* is_client */)),
|
395
396
|
&sc->base));
|
396
397
|
}
|
397
398
|
|
@@ -401,7 +402,8 @@ static void fake_server_add_handshakers(grpc_exec_ctx *exec_ctx,
|
|
401
402
|
grpc_handshake_manager_add(
|
402
403
|
handshake_mgr,
|
403
404
|
grpc_security_handshaker_create(
|
404
|
-
exec_ctx,
|
405
|
+
exec_ctx, tsi_create_adapter_handshaker(
|
406
|
+
tsi_create_fake_handshaker(false /* is_client */)),
|
405
407
|
&sc->base));
|
406
408
|
}
|
407
409
|
|
@@ -423,12 +425,8 @@ grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
|
|
423
425
|
c->base.check_call_host = fake_channel_check_call_host;
|
424
426
|
c->base.add_handshakers = fake_channel_add_handshakers;
|
425
427
|
c->target = gpr_strdup(target);
|
426
|
-
const
|
427
|
-
|
428
|
-
if (expected_target_arg != NULL) {
|
429
|
-
GPR_ASSERT(expected_target_arg->type == GRPC_ARG_STRING);
|
430
|
-
c->expected_targets = gpr_strdup(expected_target_arg->value.string);
|
431
|
-
}
|
428
|
+
const char *expected_targets = grpc_fake_transport_get_expected_targets(args);
|
429
|
+
c->expected_targets = gpr_strdup(expected_targets);
|
432
430
|
c->is_lb_channel = (grpc_lb_targets_info_find_in_args(args) != NULL);
|
433
431
|
return &c->base;
|
434
432
|
}
|
@@ -500,8 +498,10 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx *exec_ctx,
|
|
500
498
|
}
|
501
499
|
|
502
500
|
// Create handshakers.
|
503
|
-
grpc_handshake_manager_add(
|
504
|
-
|
501
|
+
grpc_handshake_manager_add(
|
502
|
+
handshake_mgr,
|
503
|
+
grpc_security_handshaker_create(
|
504
|
+
exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base));
|
505
505
|
}
|
506
506
|
|
507
507
|
static void ssl_server_add_handshakers(grpc_exec_ctx *exec_ctx,
|
@@ -520,8 +520,10 @@ static void ssl_server_add_handshakers(grpc_exec_ctx *exec_ctx,
|
|
520
520
|
}
|
521
521
|
|
522
522
|
// Create handshakers.
|
523
|
-
grpc_handshake_manager_add(
|
524
|
-
|
523
|
+
grpc_handshake_manager_add(
|
524
|
+
handshake_mgr,
|
525
|
+
grpc_security_handshaker_create(
|
526
|
+
exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base));
|
525
527
|
}
|
526
528
|
|
527
529
|
static int ssl_host_matches_name(const tsi_peer *peer, const char *peer_name) {
|
@@ -699,6 +701,7 @@ static grpc_security_connector_vtable ssl_channel_vtable = {
|
|
699
701
|
static grpc_security_connector_vtable ssl_server_vtable = {
|
700
702
|
ssl_server_destroy, ssl_server_check_peer};
|
701
703
|
|
704
|
+
/* returns a NULL terminated slice. */
|
702
705
|
static grpc_slice compute_default_pem_root_certs_once(void) {
|
703
706
|
grpc_slice result = grpc_empty_slice();
|
704
707
|
|
@@ -707,7 +710,7 @@ static grpc_slice compute_default_pem_root_certs_once(void) {
|
|
707
710
|
gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR);
|
708
711
|
if (default_root_certs_path != NULL) {
|
709
712
|
GRPC_LOG_IF_ERROR("load_file",
|
710
|
-
grpc_load_file(default_root_certs_path,
|
713
|
+
grpc_load_file(default_root_certs_path, 1, &result));
|
711
714
|
gpr_free(default_root_certs_path);
|
712
715
|
}
|
713
716
|
|
@@ -718,15 +721,18 @@ static grpc_slice compute_default_pem_root_certs_once(void) {
|
|
718
721
|
ovrd_res = ssl_roots_override_cb(&pem_root_certs);
|
719
722
|
if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) {
|
720
723
|
GPR_ASSERT(pem_root_certs != NULL);
|
721
|
-
result =
|
724
|
+
result = grpc_slice_from_copied_buffer(
|
725
|
+
pem_root_certs,
|
726
|
+
strlen(pem_root_certs) + 1); // NULL terminator.
|
722
727
|
}
|
728
|
+
gpr_free(pem_root_certs);
|
723
729
|
}
|
724
730
|
|
725
731
|
/* Fall back to installed certs if needed. */
|
726
732
|
if (GRPC_SLICE_IS_EMPTY(result) &&
|
727
733
|
ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) {
|
728
734
|
GRPC_LOG_IF_ERROR("load_file",
|
729
|
-
grpc_load_file(installed_roots_path,
|
735
|
+
grpc_load_file(installed_roots_path, 1, &result));
|
730
736
|
}
|
731
737
|
return result;
|
732
738
|
}
|
@@ -766,13 +772,14 @@ get_tsi_client_certificate_request_type(
|
|
766
772
|
}
|
767
773
|
}
|
768
774
|
|
769
|
-
|
775
|
+
const char *grpc_get_default_ssl_roots(void) {
|
770
776
|
/* TODO(jboeuf@google.com): Maybe revisit the approach which consists in
|
771
777
|
loading all the roots once for the lifetime of the process. */
|
772
778
|
static gpr_once once = GPR_ONCE_INIT;
|
773
779
|
gpr_once_init(&once, init_default_pem_root_certs);
|
774
|
-
|
775
|
-
|
780
|
+
return GRPC_SLICE_IS_EMPTY(default_pem_root_certs)
|
781
|
+
? NULL
|
782
|
+
: (const char *)GRPC_SLICE_START_PTR(default_pem_root_certs);
|
776
783
|
}
|
777
784
|
|
778
785
|
grpc_security_status grpc_ssl_channel_security_connector_create(
|
@@ -780,22 +787,16 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
|
|
780
787
|
const grpc_ssl_config *config, const char *target_name,
|
781
788
|
const char *overridden_target_name, grpc_channel_security_connector **sc) {
|
782
789
|
size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions();
|
783
|
-
const
|
790
|
+
const char **alpn_protocol_strings =
|
784
791
|
gpr_malloc(sizeof(const char *) * num_alpn_protocols);
|
785
|
-
unsigned char *alpn_protocol_string_lengths =
|
786
|
-
gpr_malloc(sizeof(unsigned char) * num_alpn_protocols);
|
787
792
|
tsi_result result = TSI_OK;
|
788
793
|
grpc_ssl_channel_security_connector *c;
|
789
794
|
size_t i;
|
790
|
-
const
|
791
|
-
size_t pem_root_certs_size;
|
795
|
+
const char *pem_root_certs;
|
792
796
|
char *port;
|
793
797
|
|
794
798
|
for (i = 0; i < num_alpn_protocols; i++) {
|
795
|
-
alpn_protocol_strings[i] =
|
796
|
-
(const unsigned char *)grpc_chttp2_get_alpn_version_index(i);
|
797
|
-
alpn_protocol_string_lengths[i] =
|
798
|
-
(unsigned char)strlen(grpc_chttp2_get_alpn_version_index(i));
|
799
|
+
alpn_protocol_strings[i] = grpc_chttp2_get_alpn_version_index(i);
|
799
800
|
}
|
800
801
|
|
801
802
|
if (config == NULL || target_name == NULL) {
|
@@ -803,14 +804,13 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
|
|
803
804
|
goto error;
|
804
805
|
}
|
805
806
|
if (config->pem_root_certs == NULL) {
|
806
|
-
|
807
|
-
if (pem_root_certs == NULL
|
807
|
+
pem_root_certs = grpc_get_default_ssl_roots();
|
808
|
+
if (pem_root_certs == NULL) {
|
808
809
|
gpr_log(GPR_ERROR, "Could not get default pem root certs.");
|
809
810
|
goto error;
|
810
811
|
}
|
811
812
|
} else {
|
812
813
|
pem_root_certs = config->pem_root_certs;
|
813
|
-
pem_root_certs_size = config->pem_root_certs_size;
|
814
814
|
}
|
815
815
|
|
816
816
|
c = gpr_zalloc(sizeof(grpc_ssl_channel_security_connector));
|
@@ -827,11 +827,12 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
|
|
827
827
|
if (overridden_target_name != NULL) {
|
828
828
|
c->overridden_target_name = gpr_strdup(overridden_target_name);
|
829
829
|
}
|
830
|
+
|
831
|
+
bool has_key_cert_pair = config->pem_key_cert_pair.private_key != NULL &&
|
832
|
+
config->pem_key_cert_pair.cert_chain != NULL;
|
830
833
|
result = tsi_create_ssl_client_handshaker_factory(
|
831
|
-
config->
|
832
|
-
|
833
|
-
pem_root_certs_size, ssl_cipher_suites(), alpn_protocol_strings,
|
834
|
-
alpn_protocol_string_lengths, (uint16_t)num_alpn_protocols,
|
834
|
+
has_key_cert_pair ? &config->pem_key_cert_pair : NULL, pem_root_certs,
|
835
|
+
ssl_cipher_suites(), alpn_protocol_strings, (uint16_t)num_alpn_protocols,
|
835
836
|
&c->handshaker_factory);
|
836
837
|
if (result != TSI_OK) {
|
837
838
|
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
|
@@ -842,12 +843,10 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
|
|
842
843
|
}
|
843
844
|
*sc = &c->base;
|
844
845
|
gpr_free((void *)alpn_protocol_strings);
|
845
|
-
gpr_free(alpn_protocol_string_lengths);
|
846
846
|
return GRPC_SECURITY_OK;
|
847
847
|
|
848
848
|
error:
|
849
849
|
gpr_free((void *)alpn_protocol_strings);
|
850
|
-
gpr_free(alpn_protocol_string_lengths);
|
851
850
|
return GRPC_SECURITY_ERROR;
|
852
851
|
}
|
853
852
|
|
@@ -855,19 +854,14 @@ grpc_security_status grpc_ssl_server_security_connector_create(
|
|
855
854
|
grpc_exec_ctx *exec_ctx, const grpc_ssl_server_config *config,
|
856
855
|
grpc_server_security_connector **sc) {
|
857
856
|
size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions();
|
858
|
-
const
|
857
|
+
const char **alpn_protocol_strings =
|
859
858
|
gpr_malloc(sizeof(const char *) * num_alpn_protocols);
|
860
|
-
unsigned char *alpn_protocol_string_lengths =
|
861
|
-
gpr_malloc(sizeof(unsigned char) * num_alpn_protocols);
|
862
859
|
tsi_result result = TSI_OK;
|
863
860
|
grpc_ssl_server_security_connector *c;
|
864
861
|
size_t i;
|
865
862
|
|
866
863
|
for (i = 0; i < num_alpn_protocols; i++) {
|
867
|
-
alpn_protocol_strings[i] =
|
868
|
-
(const unsigned char *)grpc_chttp2_get_alpn_version_index(i);
|
869
|
-
alpn_protocol_string_lengths[i] =
|
870
|
-
(unsigned char)strlen(grpc_chttp2_get_alpn_version_index(i));
|
864
|
+
alpn_protocol_strings[i] = grpc_chttp2_get_alpn_version_index(i);
|
871
865
|
}
|
872
866
|
|
873
867
|
if (config == NULL || config->num_key_cert_pairs == 0) {
|
@@ -880,15 +874,11 @@ grpc_security_status grpc_ssl_server_security_connector_create(
|
|
880
874
|
c->base.base.url_scheme = GRPC_SSL_URL_SCHEME;
|
881
875
|
c->base.base.vtable = &ssl_server_vtable;
|
882
876
|
result = tsi_create_ssl_server_handshaker_factory_ex(
|
883
|
-
|
884
|
-
config->
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
get_tsi_client_certificate_request_type(
|
889
|
-
config->client_certificate_request),
|
890
|
-
ssl_cipher_suites(), alpn_protocol_strings, alpn_protocol_string_lengths,
|
891
|
-
(uint16_t)num_alpn_protocols, &c->handshaker_factory);
|
877
|
+
config->pem_key_cert_pairs, config->num_key_cert_pairs,
|
878
|
+
config->pem_root_certs, get_tsi_client_certificate_request_type(
|
879
|
+
config->client_certificate_request),
|
880
|
+
ssl_cipher_suites(), alpn_protocol_strings, (uint16_t)num_alpn_protocols,
|
881
|
+
&c->handshaker_factory);
|
892
882
|
if (result != TSI_OK) {
|
893
883
|
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
|
894
884
|
tsi_result_to_string(result));
|
@@ -899,11 +889,9 @@ grpc_security_status grpc_ssl_server_security_connector_create(
|
|
899
889
|
c->base.add_handshakers = ssl_server_add_handshakers;
|
900
890
|
*sc = &c->base;
|
901
891
|
gpr_free((void *)alpn_protocol_strings);
|
902
|
-
gpr_free(alpn_protocol_string_lengths);
|
903
892
|
return GRPC_SECURITY_OK;
|
904
893
|
|
905
894
|
error:
|
906
895
|
gpr_free((void *)alpn_protocol_strings);
|
907
|
-
gpr_free(alpn_protocol_string_lengths);
|
908
896
|
return GRPC_SECURITY_ERROR;
|
909
897
|
}
|