grpc 1.19.0 → 1.20.0.pre1
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 +4131 -7903
- data/include/grpc/grpc.h +11 -6
- data/include/grpc/grpc_security.h +51 -9
- data/include/grpc/impl/codegen/byte_buffer.h +13 -0
- data/include/grpc/impl/codegen/grpc_types.h +4 -0
- data/include/grpc/impl/codegen/port_platform.h +37 -6
- data/include/grpc/impl/codegen/sync_posix.h +18 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +560 -236
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +2 -2
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +22 -34
- data/src/core/ext/filters/client_channel/client_channel_factory.h +19 -38
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +7 -4
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -2
- data/src/core/ext/filters/client_channel/lb_policy.cc +105 -28
- data/src/core/ext/filters/client_channel/lb_policy.h +259 -141
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +29 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +789 -803
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +2 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +7 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +8 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +127 -219
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +103 -282
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +4 -10
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +709 -906
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +0 -43
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +8 -8
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -6
- data/src/core/ext/filters/client_channel/resolver.cc +54 -1
- data/src/core/ext/filters/client_channel/resolver.h +51 -22
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +34 -86
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +29 -41
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +32 -78
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +109 -72
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +13 -8
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +28 -63
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -1
- data/src/core/ext/filters/client_channel/resolver_registry.cc +5 -2
- data/src/core/ext/filters/client_channel/resolver_registry.h +5 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +69 -49
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +11 -8
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +568 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +141 -0
- data/src/core/ext/filters/client_channel/server_address.cc +0 -48
- data/src/core/ext/filters/client_channel/server_address.h +0 -10
- data/src/core/{lib/transport → ext/filters/client_channel}/service_config.cc +10 -5
- data/src/core/{lib/transport → ext/filters/client_channel}/service_config.h +16 -12
- data/src/core/ext/filters/client_channel/subchannel.cc +11 -16
- data/src/core/ext/filters/client_channel/subchannel.h +3 -0
- data/src/core/ext/filters/max_age/max_age_filter.cc +4 -1
- data/src/core/ext/filters/message_size/message_size_filter.cc +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +45 -45
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +133 -134
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +4 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +37 -29
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +9 -5
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +6 -1
- data/src/core/ext/transport/chttp2/transport/internal.h +5 -4
- data/src/core/ext/transport/chttp2/transport/parsing.cc +9 -9
- data/src/core/ext/transport/chttp2/transport/writing.cc +1 -1
- data/src/core/ext/transport/inproc/inproc_transport.cc +8 -0
- data/src/core/lib/channel/channel_args.cc +2 -0
- data/src/core/lib/channel/channel_args.h +3 -0
- data/src/core/lib/channel/channel_stack.h +1 -1
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channel_trace.h +4 -4
- data/src/core/lib/channel/channelz.cc +32 -19
- data/src/core/lib/channel/channelz.h +4 -4
- data/src/core/lib/channel/channelz_registry.cc +1 -1
- data/src/core/lib/channel/context.h +0 -3
- data/src/core/lib/channel/handshaker_registry.cc +7 -3
- data/src/core/lib/compression/algorithm_metadata.h +3 -3
- data/src/core/lib/compression/compression.cc +1 -1
- data/src/core/lib/compression/compression_internal.cc +2 -2
- data/src/core/lib/compression/stream_compression_gzip.cc +1 -1
- data/src/core/lib/debug/trace.h +2 -1
- data/src/core/lib/gpr/cpu_posix.cc +5 -3
- data/src/core/lib/gpr/sync_posix.cc +65 -4
- data/src/core/lib/gprpp/atomic.h +75 -5
- data/src/core/lib/gprpp/fork.cc +0 -2
- data/src/core/lib/gprpp/orphanable.h +3 -2
- data/src/core/lib/gprpp/ref_counted.h +9 -11
- data/src/core/lib/gprpp/thd.h +42 -7
- data/src/core/lib/gprpp/thd_posix.cc +31 -13
- data/src/core/lib/gprpp/thd_windows.cc +47 -34
- data/src/core/lib/http/httpcli.cc +3 -2
- data/src/core/lib/http/httpcli_security_connector.cc +0 -1
- data/src/core/lib/http/parser.cc +2 -1
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/buffer_list.h +1 -1
- data/src/core/lib/iomgr/endpoint.cc +2 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/error.cc +9 -9
- data/src/core/lib/iomgr/error.h +4 -3
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +6 -0
- data/src/core/lib/iomgr/ev_epollex_linux.cc +14 -9
- data/src/core/lib/iomgr/ev_poll_posix.cc +7 -481
- data/src/core/lib/iomgr/ev_posix.cc +7 -3
- data/src/core/lib/iomgr/ev_posix.h +8 -0
- data/src/core/lib/iomgr/executor.cc +13 -0
- data/src/core/lib/iomgr/executor.h +2 -1
- data/src/core/lib/iomgr/internal_errqueue.cc +2 -4
- data/src/core/lib/iomgr/iomgr.cc +5 -0
- data/src/core/lib/iomgr/iomgr.h +7 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +9 -2
- data/src/core/lib/iomgr/iomgr_internal.cc +6 -0
- data/src/core/lib/iomgr/iomgr_internal.h +9 -1
- data/src/core/lib/iomgr/iomgr_posix.cc +10 -2
- data/src/core/lib/iomgr/iomgr_windows.cc +10 -2
- data/src/core/lib/iomgr/port.h +19 -0
- data/src/core/lib/iomgr/tcp_client_windows.cc +6 -4
- data/src/core/lib/iomgr/tcp_custom.cc +1 -1
- data/src/core/lib/iomgr/tcp_posix.cc +158 -54
- data/src/core/lib/iomgr/tcp_windows.cc +1 -1
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +1 -19
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +10 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +3 -6
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +129 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.h +62 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +7 -2
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +28 -17
- data/src/core/lib/security/security_connector/ssl_utils.cc +134 -0
- data/src/core/lib/security/security_connector/ssl_utils.h +32 -0
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +426 -0
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +122 -0
- data/src/core/lib/security/transport/auth_filters.h +2 -2
- data/src/core/lib/security/transport/client_auth_filter.cc +35 -39
- data/src/core/lib/security/transport/secure_endpoint.cc +2 -2
- data/src/core/lib/security/transport/security_handshaker.cc +4 -3
- data/src/core/lib/slice/percent_encoding.cc +3 -3
- data/src/core/lib/slice/percent_encoding.h +3 -3
- data/src/core/lib/slice/slice.cc +27 -30
- data/src/core/lib/slice/slice_hash_table.h +2 -2
- data/src/core/lib/slice/slice_intern.cc +1 -1
- data/src/core/lib/slice/slice_internal.h +14 -3
- data/src/core/lib/slice/slice_weak_hash_table.h +4 -4
- data/src/core/lib/surface/byte_buffer_reader.cc +17 -0
- data/src/core/lib/surface/call.cc +8 -3
- data/src/core/lib/surface/completion_queue.cc +134 -148
- data/src/core/lib/surface/init.cc +78 -30
- data/src/core/lib/surface/init.h +1 -0
- data/src/core/lib/surface/lame_client.cc +4 -6
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/metadata.cc +66 -33
- data/src/core/lib/transport/metadata_batch.cc +1 -1
- data/src/core/lib/transport/metadata_batch.h +1 -1
- data/src/core/lib/transport/timeout_encoding.cc +1 -1
- data/src/core/lib/transport/timeout_encoding.h +1 -1
- data/src/core/lib/transport/transport.h +4 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +4 -3
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +1 -5
- data/src/core/tsi/ssl_transport_security.h +24 -4
- data/src/ruby/bin/math_pb.rb +18 -16
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +13 -10
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +18 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +3 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +58 -56
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -0
- data/third_party/cares/cares/ares.h +12 -0
- data/third_party/cares/cares/ares_create_query.c +5 -1
- data/third_party/cares/cares/ares_data.c +74 -73
- data/third_party/cares/cares/ares_destroy.c +6 -1
- data/third_party/cares/cares/ares_gethostbyaddr.c +5 -5
- data/third_party/cares/cares/ares_gethostbyname.c +15 -4
- data/third_party/cares/cares/ares_getnameinfo.c +11 -0
- data/third_party/cares/cares/ares_init.c +274 -173
- data/third_party/cares/cares/ares_library_init.c +21 -3
- data/third_party/cares/cares/ares_options.c +6 -2
- data/third_party/cares/cares/ares_parse_naptr_reply.c +7 -6
- data/third_party/cares/cares/ares_parse_ptr_reply.c +4 -2
- data/third_party/cares/cares/ares_platform.c +7 -0
- data/third_party/cares/cares/ares_private.h +19 -11
- data/third_party/cares/cares/ares_process.c +27 -2
- data/third_party/cares/cares/ares_rules.h +1 -1
- data/third_party/cares/cares/ares_search.c +7 -0
- data/third_party/cares/cares/ares_send.c +6 -0
- data/third_party/cares/cares/ares_strsplit.c +174 -0
- data/third_party/cares/cares/ares_strsplit.h +43 -0
- data/third_party/cares/cares/ares_version.h +4 -4
- data/third_party/cares/cares/config-win32.h +1 -1
- data/third_party/cares/cares/inet_ntop.c +2 -3
- data/third_party/cares/config_darwin/ares_config.h +3 -0
- data/third_party/cares/config_freebsd/ares_config.h +3 -0
- data/third_party/cares/config_linux/ares_config.h +3 -0
- data/third_party/cares/config_openbsd/ares_config.h +3 -0
- metadata +39 -37
- data/src/core/ext/filters/client_channel/request_routing.cc +0 -946
- data/src/core/ext/filters/client_channel/request_routing.h +0 -181
- data/src/core/lib/gprpp/atomic_with_atm.h +0 -57
- data/src/core/lib/gprpp/atomic_with_std.h +0 -35
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +0 -107
- data/src/core/lib/iomgr/wakeup_fd_cv.h +0 -69
@@ -241,7 +241,7 @@ static void on_read(void* tcpp, grpc_error* error) {
|
|
241
241
|
#define DEFAULT_TARGET_READ_SIZE 8192
|
242
242
|
#define MAX_WSABUF_COUNT 16
|
243
243
|
static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
|
244
|
-
grpc_closure* cb) {
|
244
|
+
grpc_closure* cb, bool urgent) {
|
245
245
|
grpc_tcp* tcp = (grpc_tcp*)ep;
|
246
246
|
grpc_winsocket* handle = tcp->socket;
|
247
247
|
grpc_winsocket_callback_info* info = &handle->read_info;
|
@@ -23,7 +23,6 @@
|
|
23
23
|
#ifdef GRPC_POSIX_WAKEUP_FD
|
24
24
|
|
25
25
|
#include <stddef.h>
|
26
|
-
#include "src/core/lib/iomgr/wakeup_fd_cv.h"
|
27
26
|
#include "src/core/lib/iomgr/wakeup_fd_pipe.h"
|
28
27
|
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
|
29
28
|
|
@@ -51,37 +50,20 @@ void grpc_wakeup_fd_global_destroy(void) { wakeup_fd_vtable = nullptr; }
|
|
51
50
|
|
52
51
|
int grpc_has_wakeup_fd(void) { return has_real_wakeup_fd; }
|
53
52
|
|
54
|
-
int grpc_cv_wakeup_fds_enabled(void) { return cv_wakeup_fds_enabled; }
|
55
|
-
|
56
|
-
void grpc_enable_cv_wakeup_fds(int enable) { cv_wakeup_fds_enabled = enable; }
|
57
|
-
|
58
53
|
grpc_error* grpc_wakeup_fd_init(grpc_wakeup_fd* fd_info) {
|
59
|
-
if (cv_wakeup_fds_enabled) {
|
60
|
-
return grpc_cv_wakeup_fd_vtable.init(fd_info);
|
61
|
-
}
|
62
54
|
return wakeup_fd_vtable->init(fd_info);
|
63
55
|
}
|
64
56
|
|
65
57
|
grpc_error* grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd* fd_info) {
|
66
|
-
if (cv_wakeup_fds_enabled) {
|
67
|
-
return grpc_cv_wakeup_fd_vtable.consume(fd_info);
|
68
|
-
}
|
69
58
|
return wakeup_fd_vtable->consume(fd_info);
|
70
59
|
}
|
71
60
|
|
72
61
|
grpc_error* grpc_wakeup_fd_wakeup(grpc_wakeup_fd* fd_info) {
|
73
|
-
if (cv_wakeup_fds_enabled) {
|
74
|
-
return grpc_cv_wakeup_fd_vtable.wakeup(fd_info);
|
75
|
-
}
|
76
62
|
return wakeup_fd_vtable->wakeup(fd_info);
|
77
63
|
}
|
78
64
|
|
79
65
|
void grpc_wakeup_fd_destroy(grpc_wakeup_fd* fd_info) {
|
80
|
-
|
81
|
-
grpc_cv_wakeup_fd_vtable.destroy(fd_info);
|
82
|
-
} else {
|
83
|
-
wakeup_fd_vtable->destroy(fd_info);
|
84
|
-
}
|
66
|
+
wakeup_fd_vtable->destroy(fd_info);
|
85
67
|
}
|
86
68
|
|
87
69
|
#endif /* GRPC_POSIX_WAKEUP_FD */
|
@@ -134,7 +134,8 @@ static void jose_header_destroy(jose_header* h) {
|
|
134
134
|
}
|
135
135
|
|
136
136
|
/* Takes ownership of json and buffer. */
|
137
|
-
static jose_header* jose_header_from_json(grpc_json* json,
|
137
|
+
static jose_header* jose_header_from_json(grpc_json* json,
|
138
|
+
const grpc_slice& buffer) {
|
138
139
|
grpc_json* cur;
|
139
140
|
jose_header* h = static_cast<jose_header*>(gpr_zalloc(sizeof(jose_header)));
|
140
141
|
h->buffer = buffer;
|
@@ -235,7 +236,8 @@ gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims* claims) {
|
|
235
236
|
}
|
236
237
|
|
237
238
|
/* Takes ownership of json and buffer even in case of failure. */
|
238
|
-
grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json,
|
239
|
+
grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json,
|
240
|
+
const grpc_slice& buffer) {
|
239
241
|
grpc_json* cur;
|
240
242
|
grpc_jwt_claims* claims =
|
241
243
|
static_cast<grpc_jwt_claims*>(gpr_malloc(sizeof(grpc_jwt_claims)));
|
@@ -350,7 +352,7 @@ typedef struct {
|
|
350
352
|
/* Takes ownership of the header, claims and signature. */
|
351
353
|
static verifier_cb_ctx* verifier_cb_ctx_create(
|
352
354
|
grpc_jwt_verifier* verifier, grpc_pollset* pollset, jose_header* header,
|
353
|
-
grpc_jwt_claims* claims, const char* audience, grpc_slice signature,
|
355
|
+
grpc_jwt_claims* claims, const char* audience, const grpc_slice& signature,
|
354
356
|
const char* signed_jwt, size_t signed_jwt_len, void* user_data,
|
355
357
|
grpc_jwt_verification_done_cb cb) {
|
356
358
|
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
@@ -602,7 +604,8 @@ static EVP_PKEY* find_verification_key(const grpc_json* json,
|
|
602
604
|
}
|
603
605
|
|
604
606
|
static int verify_jwt_signature(EVP_PKEY* key, const char* alg,
|
605
|
-
grpc_slice signature,
|
607
|
+
const grpc_slice& signature,
|
608
|
+
const grpc_slice& signed_data) {
|
606
609
|
EVP_MD_CTX* md_ctx = EVP_MD_CTX_create();
|
607
610
|
const EVP_MD* md = evp_md_from_alg(alg);
|
608
611
|
int result = 0;
|
@@ -621,8 +624,9 @@ static int verify_jwt_signature(EVP_PKEY* key, const char* alg,
|
|
621
624
|
gpr_log(GPR_ERROR, "EVP_DigestVerifyUpdate failed.");
|
622
625
|
goto end;
|
623
626
|
}
|
624
|
-
if (EVP_DigestVerifyFinal(
|
625
|
-
|
627
|
+
if (EVP_DigestVerifyFinal(
|
628
|
+
md_ctx, const_cast<uint8_t*>(GRPC_SLICE_START_PTR(signature)),
|
629
|
+
GRPC_SLICE_LENGTH(signature)) != 1) {
|
626
630
|
gpr_log(GPR_ERROR, "JWT signature verification failed.");
|
627
631
|
goto end;
|
628
632
|
}
|
@@ -115,7 +115,8 @@ void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
|
|
115
115
|
|
116
116
|
/* --- TESTING ONLY exposed functions. --- */
|
117
117
|
|
118
|
-
grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json,
|
118
|
+
grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json,
|
119
|
+
const grpc_slice& buffer);
|
119
120
|
grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
|
120
121
|
const char* audience);
|
121
122
|
const char* grpc_jwt_issuer_email_domain(const char* issuer);
|
@@ -167,19 +167,16 @@ struct grpc_tls_credentials_options
|
|
167
167
|
grpc_ssl_client_certificate_request_type cert_request_type() const {
|
168
168
|
return cert_request_type_;
|
169
169
|
}
|
170
|
-
|
170
|
+
grpc_tls_key_materials_config* key_materials_config() const {
|
171
171
|
return key_materials_config_.get();
|
172
172
|
}
|
173
|
-
|
173
|
+
grpc_tls_credential_reload_config* credential_reload_config() const {
|
174
174
|
return credential_reload_config_.get();
|
175
175
|
}
|
176
|
-
|
176
|
+
grpc_tls_server_authorization_check_config*
|
177
177
|
server_authorization_check_config() const {
|
178
178
|
return server_authorization_check_config_.get();
|
179
179
|
}
|
180
|
-
grpc_tls_key_materials_config* mutable_key_materials_config() {
|
181
|
-
return key_materials_config_.get();
|
182
|
-
}
|
183
180
|
|
184
181
|
/* Setters for member fields. */
|
185
182
|
void set_cert_request_type(
|
@@ -0,0 +1,129 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2018 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include <grpc/support/port_platform.h>
|
20
|
+
|
21
|
+
#include "src/core/lib/security/credentials/tls/spiffe_credentials.h"
|
22
|
+
|
23
|
+
#include <cstring>
|
24
|
+
|
25
|
+
#include <grpc/grpc.h>
|
26
|
+
#include <grpc/support/alloc.h>
|
27
|
+
#include <grpc/support/log.h>
|
28
|
+
#include <grpc/support/string_util.h>
|
29
|
+
|
30
|
+
#include "src/core/lib/channel/channel_args.h"
|
31
|
+
#include "src/core/lib/security/security_connector/tls/spiffe_security_connector.h"
|
32
|
+
|
33
|
+
#define GRPC_CREDENTIALS_TYPE_SPIFFE "Spiffe"
|
34
|
+
|
35
|
+
namespace {
|
36
|
+
|
37
|
+
bool CredentialOptionSanityCheck(const grpc_tls_credentials_options* options,
|
38
|
+
bool is_client) {
|
39
|
+
if (options == nullptr) {
|
40
|
+
gpr_log(GPR_ERROR, "SPIFFE TLS credentials options is nullptr.");
|
41
|
+
return false;
|
42
|
+
}
|
43
|
+
if (options->key_materials_config() == nullptr &&
|
44
|
+
options->credential_reload_config() == nullptr) {
|
45
|
+
gpr_log(
|
46
|
+
GPR_ERROR,
|
47
|
+
"SPIFFE TLS credentials options must specify either key materials or "
|
48
|
+
"credential reload config.");
|
49
|
+
return false;
|
50
|
+
}
|
51
|
+
if (!is_client && options->server_authorization_check_config() != nullptr) {
|
52
|
+
gpr_log(GPR_INFO,
|
53
|
+
"Server's credentials options should not contain server "
|
54
|
+
"authorization check config.");
|
55
|
+
}
|
56
|
+
return true;
|
57
|
+
}
|
58
|
+
|
59
|
+
} // namespace
|
60
|
+
|
61
|
+
SpiffeCredentials::SpiffeCredentials(
|
62
|
+
grpc_core::RefCountedPtr<grpc_tls_credentials_options> options)
|
63
|
+
: grpc_channel_credentials(GRPC_CREDENTIALS_TYPE_SPIFFE),
|
64
|
+
options_(std::move(options)) {}
|
65
|
+
|
66
|
+
SpiffeCredentials::~SpiffeCredentials() {}
|
67
|
+
|
68
|
+
grpc_core::RefCountedPtr<grpc_channel_security_connector>
|
69
|
+
SpiffeCredentials::create_security_connector(
|
70
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
|
71
|
+
const char* target_name, const grpc_channel_args* args,
|
72
|
+
grpc_channel_args** new_args) {
|
73
|
+
const char* overridden_target_name = nullptr;
|
74
|
+
tsi_ssl_session_cache* ssl_session_cache = nullptr;
|
75
|
+
for (size_t i = 0; args != nullptr && i < args->num_args; i++) {
|
76
|
+
grpc_arg* arg = &args->args[i];
|
77
|
+
if (strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == 0 &&
|
78
|
+
arg->type == GRPC_ARG_STRING) {
|
79
|
+
overridden_target_name = arg->value.string;
|
80
|
+
}
|
81
|
+
if (strcmp(arg->key, GRPC_SSL_SESSION_CACHE_ARG) == 0 &&
|
82
|
+
arg->type == GRPC_ARG_POINTER) {
|
83
|
+
ssl_session_cache =
|
84
|
+
static_cast<tsi_ssl_session_cache*>(arg->value.pointer.p);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
grpc_core::RefCountedPtr<grpc_channel_security_connector> sc =
|
88
|
+
SpiffeChannelSecurityConnector::CreateSpiffeChannelSecurityConnector(
|
89
|
+
this->Ref(), std::move(call_creds), target_name,
|
90
|
+
overridden_target_name, ssl_session_cache);
|
91
|
+
if (sc == nullptr) {
|
92
|
+
return nullptr;
|
93
|
+
}
|
94
|
+
grpc_arg new_arg = grpc_channel_arg_string_create(
|
95
|
+
(char*)GRPC_ARG_HTTP2_SCHEME, (char*)"https");
|
96
|
+
*new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1);
|
97
|
+
return sc;
|
98
|
+
}
|
99
|
+
|
100
|
+
SpiffeServerCredentials::SpiffeServerCredentials(
|
101
|
+
grpc_core::RefCountedPtr<grpc_tls_credentials_options> options)
|
102
|
+
: grpc_server_credentials(GRPC_CREDENTIALS_TYPE_SPIFFE),
|
103
|
+
options_(std::move(options)) {}
|
104
|
+
|
105
|
+
SpiffeServerCredentials::~SpiffeServerCredentials() {}
|
106
|
+
|
107
|
+
grpc_core::RefCountedPtr<grpc_server_security_connector>
|
108
|
+
SpiffeServerCredentials::create_security_connector() {
|
109
|
+
return SpiffeServerSecurityConnector::CreateSpiffeServerSecurityConnector(
|
110
|
+
this->Ref());
|
111
|
+
}
|
112
|
+
|
113
|
+
grpc_channel_credentials* grpc_tls_spiffe_credentials_create(
|
114
|
+
grpc_tls_credentials_options* options) {
|
115
|
+
if (!CredentialOptionSanityCheck(options, true /* is_client */)) {
|
116
|
+
return nullptr;
|
117
|
+
}
|
118
|
+
return grpc_core::New<SpiffeCredentials>(
|
119
|
+
grpc_core::RefCountedPtr<grpc_tls_credentials_options>(options));
|
120
|
+
}
|
121
|
+
|
122
|
+
grpc_server_credentials* grpc_tls_spiffe_server_credentials_create(
|
123
|
+
grpc_tls_credentials_options* options) {
|
124
|
+
if (!CredentialOptionSanityCheck(options, false /* is_client */)) {
|
125
|
+
return nullptr;
|
126
|
+
}
|
127
|
+
return grpc_core::New<SpiffeServerCredentials>(
|
128
|
+
grpc_core::RefCountedPtr<grpc_tls_credentials_options>(options));
|
129
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2018 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_SPIFFE_CREDENTIALS_H
|
20
|
+
#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_SPIFFE_CREDENTIALS_H
|
21
|
+
|
22
|
+
#include <grpc/support/port_platform.h>
|
23
|
+
|
24
|
+
#include <grpc/grpc_security.h>
|
25
|
+
|
26
|
+
#include "src/core/lib/security/credentials/credentials.h"
|
27
|
+
#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
|
28
|
+
|
29
|
+
class SpiffeCredentials final : public grpc_channel_credentials {
|
30
|
+
public:
|
31
|
+
explicit SpiffeCredentials(
|
32
|
+
grpc_core::RefCountedPtr<grpc_tls_credentials_options> options);
|
33
|
+
~SpiffeCredentials() override;
|
34
|
+
|
35
|
+
grpc_core::RefCountedPtr<grpc_channel_security_connector>
|
36
|
+
create_security_connector(
|
37
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
|
38
|
+
const char* target_name, const grpc_channel_args* args,
|
39
|
+
grpc_channel_args** new_args) override;
|
40
|
+
|
41
|
+
const grpc_tls_credentials_options& options() const { return *options_; }
|
42
|
+
|
43
|
+
private:
|
44
|
+
grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
|
45
|
+
};
|
46
|
+
|
47
|
+
class SpiffeServerCredentials final : public grpc_server_credentials {
|
48
|
+
public:
|
49
|
+
explicit SpiffeServerCredentials(
|
50
|
+
grpc_core::RefCountedPtr<grpc_tls_credentials_options> options);
|
51
|
+
~SpiffeServerCredentials() override;
|
52
|
+
|
53
|
+
grpc_core::RefCountedPtr<grpc_server_security_connector>
|
54
|
+
create_security_connector() override;
|
55
|
+
|
56
|
+
const grpc_tls_credentials_options& options() const { return *options_; }
|
57
|
+
|
58
|
+
private:
|
59
|
+
grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
|
60
|
+
};
|
61
|
+
|
62
|
+
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_TLS_SPIFFE_CREDENTIALS_H */
|
@@ -26,6 +26,8 @@
|
|
26
26
|
#include <grpc/support/log.h>
|
27
27
|
#include <grpc/support/string_util.h>
|
28
28
|
|
29
|
+
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
|
30
|
+
#include "src/core/ext/filters/client_channel/lb_policy/xds/xds.h"
|
29
31
|
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
|
30
32
|
#include "src/core/lib/channel/channel_args.h"
|
31
33
|
#include "src/core/lib/channel/handshaker.h"
|
@@ -53,8 +55,11 @@ class grpc_fake_channel_security_connector final
|
|
53
55
|
target_(gpr_strdup(target)),
|
54
56
|
expected_targets_(
|
55
57
|
gpr_strdup(grpc_fake_transport_get_expected_targets(args))),
|
56
|
-
is_lb_channel_(
|
57
|
-
|
58
|
+
is_lb_channel_(
|
59
|
+
grpc_channel_args_find(
|
60
|
+
args, GRPC_ARG_ADDRESS_IS_XDS_LOAD_BALANCER) != nullptr ||
|
61
|
+
grpc_channel_args_find(
|
62
|
+
args, GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER) != nullptr) {
|
58
63
|
const grpc_arg* target_name_override_arg =
|
59
64
|
grpc_channel_args_find(args, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
|
60
65
|
if (target_name_override_arg != nullptr) {
|
@@ -104,7 +104,6 @@ class grpc_ssl_channel_security_connector final
|
|
104
104
|
config->pem_key_cert_pair->private_key != nullptr &&
|
105
105
|
config->pem_key_cert_pair->cert_chain != nullptr;
|
106
106
|
tsi_ssl_client_handshaker_options options;
|
107
|
-
memset(&options, 0, sizeof(options));
|
108
107
|
GPR_DEBUG_ASSERT(pem_root_certs != nullptr);
|
109
108
|
options.pem_root_certs = pem_root_certs;
|
110
109
|
options.root_store = root_store;
|
@@ -262,15 +261,22 @@ class grpc_ssl_server_security_connector
|
|
262
261
|
size_t num_alpn_protocols = 0;
|
263
262
|
const char** alpn_protocol_strings =
|
264
263
|
grpc_fill_alpn_protocol_strings(&num_alpn_protocols);
|
265
|
-
|
266
|
-
|
267
|
-
server_credentials->config().
|
268
|
-
|
264
|
+
tsi_ssl_server_handshaker_options options;
|
265
|
+
options.pem_key_cert_pairs =
|
266
|
+
server_credentials->config().pem_key_cert_pairs;
|
267
|
+
options.num_key_cert_pairs =
|
268
|
+
server_credentials->config().num_key_cert_pairs;
|
269
|
+
options.pem_client_root_certs =
|
270
|
+
server_credentials->config().pem_root_certs;
|
271
|
+
options.client_certificate_request =
|
269
272
|
grpc_get_tsi_client_certificate_request_type(
|
270
|
-
server_credentials->config().client_certificate_request)
|
271
|
-
|
272
|
-
|
273
|
-
|
273
|
+
server_credentials->config().client_certificate_request);
|
274
|
+
options.cipher_suites = grpc_get_ssl_cipher_suites();
|
275
|
+
options.alpn_protocols = alpn_protocol_strings;
|
276
|
+
options.num_alpn_protocols = static_cast<uint16_t>(num_alpn_protocols);
|
277
|
+
const tsi_result result =
|
278
|
+
tsi_create_ssl_server_handshaker_factory_with_options(
|
279
|
+
&options, &server_handshaker_factory_);
|
274
280
|
gpr_free((void*)alpn_protocol_strings);
|
275
281
|
if (result != TSI_OK) {
|
276
282
|
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
|
@@ -360,19 +366,24 @@ class grpc_ssl_server_security_connector
|
|
360
366
|
size_t num_alpn_protocols = 0;
|
361
367
|
const char** alpn_protocol_strings =
|
362
368
|
grpc_fill_alpn_protocol_strings(&num_alpn_protocols);
|
363
|
-
tsi_ssl_pem_key_cert_pair* cert_pairs = grpc_convert_grpc_to_tsi_cert_pairs(
|
364
|
-
config->pem_key_cert_pairs, config->num_key_cert_pairs);
|
365
369
|
tsi_ssl_server_handshaker_factory* new_handshaker_factory = nullptr;
|
366
370
|
const grpc_ssl_server_credentials* server_creds =
|
367
371
|
static_cast<const grpc_ssl_server_credentials*>(this->server_creds());
|
368
372
|
GPR_DEBUG_ASSERT(config->pem_root_certs != nullptr);
|
369
|
-
|
370
|
-
|
373
|
+
tsi_ssl_server_handshaker_options options;
|
374
|
+
options.pem_key_cert_pairs = grpc_convert_grpc_to_tsi_cert_pairs(
|
375
|
+
config->pem_key_cert_pairs, config->num_key_cert_pairs);
|
376
|
+
options.num_key_cert_pairs = config->num_key_cert_pairs;
|
377
|
+
options.pem_client_root_certs = config->pem_root_certs;
|
378
|
+
options.client_certificate_request =
|
371
379
|
grpc_get_tsi_client_certificate_request_type(
|
372
|
-
server_creds->config().client_certificate_request)
|
373
|
-
|
374
|
-
|
375
|
-
|
380
|
+
server_creds->config().client_certificate_request);
|
381
|
+
options.cipher_suites = grpc_get_ssl_cipher_suites();
|
382
|
+
options.alpn_protocols = alpn_protocol_strings;
|
383
|
+
options.num_alpn_protocols = static_cast<uint16_t>(num_alpn_protocols);
|
384
|
+
tsi_result result = tsi_create_ssl_server_handshaker_factory_with_options(
|
385
|
+
&options, &new_handshaker_factory);
|
386
|
+
gpr_free((void*)options.pem_key_cert_pairs);
|
376
387
|
gpr_free((void*)alpn_protocol_strings);
|
377
388
|
|
378
389
|
if (result != TSI_OK) {
|
@@ -112,6 +112,55 @@ grpc_get_tsi_client_certificate_request_type(
|
|
112
112
|
}
|
113
113
|
}
|
114
114
|
|
115
|
+
grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer) {
|
116
|
+
#if TSI_OPENSSL_ALPN_SUPPORT
|
117
|
+
/* Check the ALPN if ALPN is supported. */
|
118
|
+
const tsi_peer_property* p =
|
119
|
+
tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
|
120
|
+
if (p == nullptr) {
|
121
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
122
|
+
"Cannot check peer: missing selected ALPN property.");
|
123
|
+
}
|
124
|
+
if (!grpc_chttp2_is_alpn_version_supported(p->value.data, p->value.length)) {
|
125
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
126
|
+
"Cannot check peer: invalid ALPN value.");
|
127
|
+
}
|
128
|
+
#endif /* TSI_OPENSSL_ALPN_SUPPORT */
|
129
|
+
return GRPC_ERROR_NONE;
|
130
|
+
}
|
131
|
+
|
132
|
+
grpc_error* grpc_ssl_check_peer_name(const char* peer_name,
|
133
|
+
const tsi_peer* peer) {
|
134
|
+
/* Check the peer name if specified. */
|
135
|
+
if (peer_name != nullptr && !grpc_ssl_host_matches_name(peer, peer_name)) {
|
136
|
+
char* msg;
|
137
|
+
gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name);
|
138
|
+
grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
139
|
+
gpr_free(msg);
|
140
|
+
return error;
|
141
|
+
}
|
142
|
+
return GRPC_ERROR_NONE;
|
143
|
+
}
|
144
|
+
|
145
|
+
bool grpc_ssl_check_call_host(const char* host, const char* target_name,
|
146
|
+
const char* overridden_target_name,
|
147
|
+
grpc_auth_context* auth_context,
|
148
|
+
grpc_closure* on_call_host_checked,
|
149
|
+
grpc_error** error) {
|
150
|
+
grpc_security_status status = GRPC_SECURITY_ERROR;
|
151
|
+
tsi_peer peer = grpc_shallow_peer_from_ssl_auth_context(auth_context);
|
152
|
+
if (grpc_ssl_host_matches_name(&peer, host)) status = GRPC_SECURITY_OK;
|
153
|
+
if (overridden_target_name != nullptr && strcmp(host, target_name) == 0) {
|
154
|
+
status = GRPC_SECURITY_OK;
|
155
|
+
}
|
156
|
+
if (status != GRPC_SECURITY_OK) {
|
157
|
+
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
158
|
+
"call host does not match SSL server name");
|
159
|
+
}
|
160
|
+
grpc_shallow_peer_destruct(&peer);
|
161
|
+
return true;
|
162
|
+
}
|
163
|
+
|
115
164
|
const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
|
116
165
|
GPR_ASSERT(num_alpn_protocols != nullptr);
|
117
166
|
*num_alpn_protocols = grpc_chttp2_num_alpn_versions();
|
@@ -142,6 +191,18 @@ int grpc_ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) {
|
|
142
191
|
return r;
|
143
192
|
}
|
144
193
|
|
194
|
+
bool grpc_ssl_cmp_target_name(const char* target_name,
|
195
|
+
const char* other_target_name,
|
196
|
+
const char* overridden_target_name,
|
197
|
+
const char* other_overridden_target_name) {
|
198
|
+
int c = strcmp(target_name, other_target_name);
|
199
|
+
if (c != 0) return c;
|
200
|
+
return (overridden_target_name == nullptr ||
|
201
|
+
other_overridden_target_name == nullptr)
|
202
|
+
? GPR_ICMP(overridden_target_name, other_overridden_target_name)
|
203
|
+
: strcmp(overridden_target_name, other_overridden_target_name);
|
204
|
+
}
|
205
|
+
|
145
206
|
grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
|
146
207
|
const tsi_peer* peer) {
|
147
208
|
size_t i;
|
@@ -230,6 +291,79 @@ void grpc_shallow_peer_destruct(tsi_peer* peer) {
|
|
230
291
|
if (peer->properties != nullptr) gpr_free(peer->properties);
|
231
292
|
}
|
232
293
|
|
294
|
+
grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
|
295
|
+
tsi_ssl_pem_key_cert_pair* pem_key_cert_pair, const char* pem_root_certs,
|
296
|
+
tsi_ssl_session_cache* ssl_session_cache,
|
297
|
+
tsi_ssl_client_handshaker_factory** handshaker_factory) {
|
298
|
+
const char* root_certs;
|
299
|
+
const tsi_ssl_root_certs_store* root_store;
|
300
|
+
if (pem_root_certs == nullptr) {
|
301
|
+
// Use default root certificates.
|
302
|
+
root_certs = grpc_core::DefaultSslRootStore::GetPemRootCerts();
|
303
|
+
if (root_certs == nullptr) {
|
304
|
+
gpr_log(GPR_ERROR, "Could not get default pem root certs.");
|
305
|
+
return GRPC_SECURITY_ERROR;
|
306
|
+
}
|
307
|
+
root_store = grpc_core::DefaultSslRootStore::GetRootStore();
|
308
|
+
} else {
|
309
|
+
root_certs = pem_root_certs;
|
310
|
+
root_store = nullptr;
|
311
|
+
}
|
312
|
+
bool has_key_cert_pair = pem_key_cert_pair != nullptr &&
|
313
|
+
pem_key_cert_pair->private_key != nullptr &&
|
314
|
+
pem_key_cert_pair->cert_chain != nullptr;
|
315
|
+
tsi_ssl_client_handshaker_options options;
|
316
|
+
GPR_DEBUG_ASSERT(root_certs != nullptr);
|
317
|
+
options.pem_root_certs = root_certs;
|
318
|
+
options.root_store = root_store;
|
319
|
+
options.alpn_protocols =
|
320
|
+
grpc_fill_alpn_protocol_strings(&options.num_alpn_protocols);
|
321
|
+
if (has_key_cert_pair) {
|
322
|
+
options.pem_key_cert_pair = pem_key_cert_pair;
|
323
|
+
}
|
324
|
+
options.cipher_suites = grpc_get_ssl_cipher_suites();
|
325
|
+
options.session_cache = ssl_session_cache;
|
326
|
+
const tsi_result result =
|
327
|
+
tsi_create_ssl_client_handshaker_factory_with_options(&options,
|
328
|
+
handshaker_factory);
|
329
|
+
gpr_free((void*)options.alpn_protocols);
|
330
|
+
if (result != TSI_OK) {
|
331
|
+
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
|
332
|
+
tsi_result_to_string(result));
|
333
|
+
return GRPC_SECURITY_ERROR;
|
334
|
+
}
|
335
|
+
return GRPC_SECURITY_OK;
|
336
|
+
}
|
337
|
+
|
338
|
+
grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
|
339
|
+
tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs,
|
340
|
+
const char* pem_root_certs,
|
341
|
+
grpc_ssl_client_certificate_request_type client_certificate_request,
|
342
|
+
tsi_ssl_server_handshaker_factory** handshaker_factory) {
|
343
|
+
size_t num_alpn_protocols = 0;
|
344
|
+
const char** alpn_protocol_strings =
|
345
|
+
grpc_fill_alpn_protocol_strings(&num_alpn_protocols);
|
346
|
+
tsi_ssl_server_handshaker_options options;
|
347
|
+
options.pem_key_cert_pairs = pem_key_cert_pairs;
|
348
|
+
options.num_key_cert_pairs = num_key_cert_pairs;
|
349
|
+
options.pem_client_root_certs = pem_root_certs;
|
350
|
+
options.client_certificate_request =
|
351
|
+
grpc_get_tsi_client_certificate_request_type(client_certificate_request);
|
352
|
+
options.cipher_suites = grpc_get_ssl_cipher_suites();
|
353
|
+
options.alpn_protocols = alpn_protocol_strings;
|
354
|
+
options.num_alpn_protocols = static_cast<uint16_t>(num_alpn_protocols);
|
355
|
+
const tsi_result result =
|
356
|
+
tsi_create_ssl_server_handshaker_factory_with_options(&options,
|
357
|
+
handshaker_factory);
|
358
|
+
gpr_free((void*)alpn_protocol_strings);
|
359
|
+
if (result != TSI_OK) {
|
360
|
+
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
|
361
|
+
tsi_result_to_string(result));
|
362
|
+
return GRPC_SECURITY_ERROR;
|
363
|
+
}
|
364
|
+
return GRPC_SECURITY_OK;
|
365
|
+
}
|
366
|
+
|
233
367
|
/* --- Ssl cache implementation. --- */
|
234
368
|
|
235
369
|
grpc_ssl_session_cache* grpc_ssl_session_cache_create_lru(size_t capacity) {
|