grpc 1.7.3 → 1.8.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 +2106 -2116
- data/include/grpc/census.h +1 -432
- data/include/grpc/compression.h +9 -9
- data/include/grpc/grpc.h +115 -98
- data/include/grpc/grpc_cronet.h +3 -3
- data/include/grpc/grpc_posix.h +4 -4
- data/include/grpc/grpc_security.h +160 -88
- data/include/grpc/grpc_security_constants.h +7 -0
- data/include/grpc/impl/codegen/atm.h +9 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +13 -4
- data/include/grpc/impl/codegen/atm_gcc_sync.h +6 -5
- data/include/grpc/impl/codegen/atm_windows.h +23 -22
- data/include/grpc/impl/codegen/byte_buffer.h +14 -14
- data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -2
- data/include/grpc/impl/codegen/connectivity_state.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +32 -28
- data/include/grpc/impl/codegen/port_platform.h +48 -0
- data/include/grpc/impl/codegen/slice.h +10 -10
- data/include/grpc/impl/codegen/sync_generic.h +9 -3
- data/include/grpc/slice.h +16 -17
- data/include/grpc/slice_buffer.h +22 -22
- data/include/grpc/support/alloc.h +11 -11
- data/include/grpc/support/avl.h +28 -20
- data/include/grpc/support/cmdline.h +13 -13
- data/include/grpc/support/histogram.h +17 -17
- 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 +2 -2
- data/include/grpc/support/subprocess.h +5 -5
- data/include/grpc/support/sync.h +43 -27
- data/include/grpc/support/thd.h +6 -6
- data/include/grpc/support/tls_gcc.h +1 -1
- data/include/grpc/support/tls_pthread.h +1 -1
- data/src/core/ext/census/{grpc_context.c → grpc_context.cc} +5 -8
- data/src/core/ext/filters/client_channel/backup_poller.cc +165 -0
- data/src/core/ext/{census/grpc_filter.h → filters/client_channel/backup_poller.h} +12 -7
- data/src/core/ext/filters/client_channel/{channel_connectivity.c → channel_connectivity.cc} +45 -42
- data/src/core/ext/filters/client_channel/{client_channel.c → client_channel.cc} +452 -417
- data/src/core/ext/filters/client_channel/client_channel.h +16 -8
- data/src/core/ext/filters/client_channel/{client_channel_factory.c → client_channel_factory.cc} +0 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.h +29 -21
- data/src/core/ext/filters/client_channel/{client_channel_plugin.c → client_channel_plugin.cc} +15 -19
- data/src/core/ext/filters/client_channel/{connector.c → connector.cc} +0 -0
- data/src/core/ext/filters/client_channel/connector.h +29 -21
- data/src/core/ext/filters/client_channel/{http_connect_handshaker.c → http_connect_handshaker.cc} +10 -10
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +8 -0
- data/src/core/ext/filters/client_channel/{http_proxy.c → http_proxy.cc} +14 -14
- data/src/core/ext/filters/client_channel/http_proxy.h +8 -0
- data/src/core/ext/filters/client_channel/{lb_policy.c → lb_policy.cc} +47 -48
- data/src/core/ext/filters/client_channel/lb_policy.h +76 -70
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{client_load_reporting_filter.c → client_load_reporting_filter.cc} +28 -29
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb.c → grpclb.cc} +554 -563
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +17 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_channel_secure.c → grpclb_channel_secure.cc} +17 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_client_stats.c → grpclb_client_stats.cc} +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{load_balancer_api.c → load_balancer_api.cc} +64 -67
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +20 -21
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +599 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +695 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +270 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +153 -0
- data/src/core/ext/filters/client_channel/{lb_policy_factory.c → lb_policy_factory.cc} +10 -10
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +48 -40
- data/src/core/ext/filters/client_channel/{lb_policy_registry.c → lb_policy_registry.cc} +9 -9
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +11 -3
- data/src/core/ext/filters/client_channel/{parse_address.c → parse_address.cc} +24 -24
- data/src/core/ext/filters/client_channel/parse_address.h +14 -6
- data/src/core/ext/filters/client_channel/{proxy_mapper.c → proxy_mapper.cc} +0 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.h +8 -0
- data/src/core/ext/filters/client_channel/{proxy_mapper_registry.c → proxy_mapper_registry.cc} +0 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +8 -0
- data/src/core/ext/filters/client_channel/{resolver.c → resolver.cc} +21 -23
- data/src/core/ext/filters/client_channel/resolver.h +33 -27
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{dns_resolver_ares.c → dns_resolver_ares.cc} +133 -133
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +18 -9
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_ev_driver_posix.c → grpc_ares_ev_driver_posix.cc} +58 -56
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_wrapper.c → grpc_ares_wrapper.cc} +118 -115
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +23 -15
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +60 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/{dns_resolver.c → dns_resolver.cc} +100 -94
- data/src/core/ext/filters/client_channel/resolver/fake/{fake_resolver.c → fake_resolver.cc} +14 -14
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +9 -1
- data/src/core/ext/filters/client_channel/resolver/sockaddr/{sockaddr_resolver.c → sockaddr_resolver.cc} +60 -60
- data/src/core/ext/filters/client_channel/{resolver_factory.c → resolver_factory.cc} +2 -2
- data/src/core/ext/filters/client_channel/resolver_factory.h +27 -19
- data/src/core/ext/filters/client_channel/{resolver_registry.c → resolver_registry.cc} +35 -35
- data/src/core/ext/filters/client_channel/resolver_registry.h +18 -10
- data/src/core/ext/filters/client_channel/{retry_throttle.c → retry_throttle.cc} +10 -10
- data/src/core/ext/filters/client_channel/retry_throttle.h +8 -0
- data/src/core/ext/filters/client_channel/{subchannel.c → subchannel.cc} +210 -213
- data/src/core/ext/filters/client_channel/subchannel.h +68 -60
- data/src/core/ext/filters/client_channel/{subchannel_index.c → subchannel_index.cc} +52 -52
- data/src/core/ext/filters/client_channel/subchannel_index.h +22 -14
- data/src/core/ext/filters/client_channel/{uri_parser.c → uri_parser.cc} +29 -27
- data/src/core/ext/filters/client_channel/uri_parser.h +18 -10
- data/src/core/ext/filters/deadline/{deadline_filter.c → deadline_filter.cc} +12 -15
- data/src/core/ext/filters/deadline/deadline_filter.h +11 -2
- data/src/core/ext/filters/http/client/{http_client_filter.c → http_client_filter.cc} +83 -83
- data/src/core/ext/filters/http/client/http_client_filter.h +8 -0
- data/src/core/ext/filters/http/{http_filters_plugin.c → http_filters_plugin.cc} +20 -21
- data/src/core/ext/filters/http/message_compress/{message_compress_filter.c → message_compress_filter.cc} +84 -83
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +9 -1
- data/src/core/ext/filters/http/server/{http_server_filter.c → http_server_filter.cc} +80 -78
- data/src/core/ext/filters/http/server/http_server_filter.h +8 -0
- data/src/core/ext/filters/load_reporting/{server_load_reporting_filter.c → server_load_reporting_filter.cc} +29 -29
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +9 -1
- data/src/core/ext/filters/load_reporting/{server_load_reporting_plugin.c → server_load_reporting_plugin.cc} +11 -11
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +13 -5
- data/src/core/ext/filters/max_age/{max_age_filter.c → max_age_filter.cc} +46 -56
- data/src/core/ext/filters/max_age/max_age_filter.h +8 -0
- data/src/core/ext/filters/message_size/{message_size_filter.c → message_size_filter.cc} +62 -40
- data/src/core/ext/filters/message_size/message_size_filter.h +8 -0
- data/src/core/ext/filters/workarounds/{workaround_cronet_compression_filter.c → workaround_cronet_compression_filter.cc} +11 -11
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +8 -0
- data/src/core/ext/filters/workarounds/{workaround_utils.c → workaround_utils.cc} +7 -7
- data/src/core/ext/filters/workarounds/workaround_utils.h +9 -1
- data/src/core/ext/transport/chttp2/alpn/{alpn.c → alpn.cc} +3 -3
- data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -2
- data/src/core/ext/transport/chttp2/client/{chttp2_connector.c → chttp2_connector.cc} +49 -45
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +8 -0
- data/src/core/ext/transport/chttp2/client/insecure/{channel_create.c → channel_create.cc} +28 -27
- data/src/core/ext/transport/chttp2/client/insecure/{channel_create_posix.c → channel_create_posix.cc} +14 -13
- data/src/core/ext/transport/chttp2/client/secure/{secure_channel_create.c → secure_channel_create.cc} +68 -66
- data/src/core/ext/transport/chttp2/server/{chttp2_server.c → chttp2_server.cc} +76 -77
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +11 -3
- data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2.c → server_chttp2.cc} +3 -3
- data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2_posix.c → server_chttp2_posix.cc} +13 -12
- data/src/core/ext/transport/chttp2/server/secure/{server_secure_chttp2.c → server_secure_chttp2.cc} +12 -10
- data/src/core/ext/transport/chttp2/transport/{bin_decoder.c → bin_decoder.cc} +7 -7
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +15 -7
- data/src/core/ext/transport/chttp2/transport/{bin_encoder.c → bin_encoder.cc} +11 -11
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{chttp2_plugin.c → chttp2_plugin.cc} +2 -9
- data/src/core/ext/transport/chttp2/transport/{chttp2_transport.c → chttp2_transport.cc} +778 -778
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -10
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +385 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +337 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{frame_data.c → frame_data.cc} +34 -34
- data/src/core/ext/transport/chttp2/transport/frame_data.h +25 -17
- data/src/core/ext/transport/chttp2/transport/{frame_goaway.c → frame_goaway.cc} +18 -18
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +18 -10
- data/src/core/ext/transport/chttp2/transport/{frame_ping.c → frame_ping.cc} +18 -19
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +12 -4
- data/src/core/ext/transport/chttp2/transport/{frame_rst_stream.c → frame_rst_stream.cc} +16 -16
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +16 -8
- data/src/core/ext/transport/chttp2/transport/{frame_settings.c → frame_settings.cc} +23 -24
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +17 -9
- data/src/core/ext/transport/chttp2/transport/{frame_window_update.c → frame_window_update.cc} +22 -24
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +14 -6
- data/src/core/ext/transport/chttp2/transport/{hpack_encoder.c → hpack_encoder.cc} +206 -161
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +23 -13
- data/src/core/ext/transport/chttp2/transport/{hpack_parser.c → hpack_parser.cc} +340 -334
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +30 -22
- data/src/core/ext/transport/chttp2/transport/{hpack_table.c → hpack_table.cc} +25 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +19 -11
- data/src/core/ext/transport/chttp2/transport/{http2_settings.c → http2_settings.cc} +1 -1
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -2
- data/src/core/ext/transport/chttp2/transport/{huffsyms.c → huffsyms.cc} +0 -0
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{incoming_metadata.c → incoming_metadata.cc} +14 -13
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +18 -10
- data/src/core/ext/transport/chttp2/transport/internal.h +214 -340
- data/src/core/ext/transport/chttp2/transport/{parsing.c → parsing.cc} +152 -141
- data/src/core/ext/transport/chttp2/transport/{stream_lists.c → stream_lists.cc} +53 -53
- data/src/core/ext/transport/chttp2/transport/{stream_map.c → stream_map.cc} +35 -34
- data/src/core/ext/transport/chttp2/transport/stream_map.h +22 -14
- data/src/core/ext/transport/chttp2/transport/{varint.c → varint.cc} +0 -0
- data/src/core/ext/transport/chttp2/transport/varint.h +8 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +636 -0
- data/src/core/ext/transport/inproc/{inproc_plugin.c → inproc_plugin.cc} +5 -6
- data/src/core/ext/transport/inproc/{inproc_transport.c → inproc_transport.cc} +479 -544
- data/src/core/ext/transport/inproc/inproc_transport.h +4 -4
- data/src/core/lib/backoff/backoff.cc +80 -0
- data/src/core/lib/backoff/backoff.h +83 -0
- data/src/core/lib/channel/{channel_args.c → channel_args.cc} +92 -92
- data/src/core/lib/channel/channel_args.h +45 -37
- data/src/core/lib/channel/{channel_stack.c → channel_stack.cc} +67 -68
- data/src/core/lib/channel/channel_stack.h +76 -75
- data/src/core/lib/channel/{channel_stack_builder.c → channel_stack_builder.cc} +91 -91
- data/src/core/lib/channel/channel_stack_builder.h +45 -45
- data/src/core/lib/channel/{connected_channel.c → connected_channel.cc} +70 -70
- data/src/core/lib/channel/connected_channel.h +12 -4
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/channel/{handshaker.c → handshaker.cc} +7 -9
- data/src/core/lib/channel/handshaker.h +9 -1
- data/src/core/lib/channel/{handshaker_factory.c → handshaker_factory.cc} +7 -7
- data/src/core/lib/channel/handshaker_factory.h +18 -10
- data/src/core/lib/channel/{handshaker_registry.c → handshaker_registry.cc} +0 -0
- data/src/core/lib/channel/handshaker_registry.h +8 -0
- data/src/core/lib/compression/algorithm_metadata.h +8 -0
- data/src/core/lib/compression/{compression.c → compression.cc} +9 -9
- data/src/core/lib/compression/{message_compress.c → message_compress.cc} +0 -0
- data/src/core/lib/compression/message_compress.h +8 -0
- data/src/core/lib/compression/{stream_compression.c → stream_compression.cc} +12 -12
- data/src/core/lib/compression/stream_compression.h +27 -19
- data/src/core/lib/compression/{stream_compression_gzip.c → stream_compression_gzip.cc} +35 -36
- data/src/core/lib/compression/stream_compression_gzip.h +8 -0
- data/src/core/lib/compression/{stream_compression_identity.c → stream_compression_identity.cc} +19 -20
- data/src/core/lib/compression/stream_compression_identity.h +8 -0
- data/src/core/lib/debug/{stats.c → stats.cc} +19 -19
- data/src/core/lib/debug/stats.h +17 -9
- data/src/core/lib/debug/{stats_data.c → stats_data.cc} +45 -22
- data/src/core/lib/debug/stats_data.h +58 -19
- data/src/core/lib/debug/trace.cc +142 -0
- data/src/core/lib/debug/trace.h +74 -14
- data/src/core/lib/http/{format_request.c → format_request.cc} +10 -10
- data/src/core/lib/http/format_request.h +12 -4
- data/src/core/lib/http/{httpcli.c → httpcli.cc} +80 -80
- data/src/core/lib/http/httpcli.h +41 -33
- data/src/core/lib/http/{httpcli_security_connector.c → httpcli_security_connector.cc} +69 -55
- data/src/core/lib/http/{parser.c → parser.cc} +42 -42
- data/src/core/lib/http/parser.h +28 -20
- data/src/core/lib/{support → iomgr}/block_annotate.h +17 -8
- data/src/core/lib/iomgr/{call_combiner.c → call_combiner.cc} +29 -17
- data/src/core/lib/iomgr/call_combiner.h +9 -1
- data/src/core/lib/iomgr/closure.h +220 -62
- data/src/core/lib/iomgr/{combiner.c → combiner.cc} +63 -62
- data/src/core/lib/iomgr/combiner.h +16 -8
- data/src/core/lib/iomgr/{endpoint.c → endpoint.cc} +6 -0
- data/src/core/lib/iomgr/endpoint.h +47 -32
- data/src/core/lib/iomgr/endpoint_pair.h +12 -4
- data/src/core/lib/iomgr/{endpoint_pair_posix.c → endpoint_pair_posix.cc} +3 -3
- data/src/core/lib/iomgr/{endpoint_pair_uv.c → endpoint_pair_uv.cc} +2 -2
- data/src/core/lib/iomgr/{endpoint_pair_windows.c → endpoint_pair_windows.cc} +6 -6
- data/src/core/lib/iomgr/{error.c → error.cc} +125 -124
- data/src/core/lib/iomgr/error.h +32 -27
- data/src/core/lib/iomgr/error_internal.h +11 -2
- data/src/core/lib/iomgr/{ev_epoll1_linux.c → ev_epoll1_linux.cc} +214 -215
- data/src/core/lib/iomgr/ev_epoll1_linux.h +9 -1
- data/src/core/lib/iomgr/ev_epollex_linux.cc +1488 -0
- data/src/core/lib/iomgr/ev_epollex_linux.h +9 -1
- data/src/core/lib/iomgr/{ev_epollsig_linux.c → ev_epollsig_linux.cc} +304 -305
- data/src/core/lib/iomgr/ev_epollsig_linux.h +12 -4
- data/src/core/lib/iomgr/{ev_poll_posix.c → ev_poll_posix.cc} +272 -283
- data/src/core/lib/iomgr/ev_poll_posix.h +10 -2
- data/src/core/lib/iomgr/ev_posix.cc +288 -0
- data/src/core/lib/iomgr/ev_posix.h +75 -67
- data/src/core/lib/iomgr/{ev_windows.c → ev_windows.cc} +2 -2
- data/src/core/lib/iomgr/exec_ctx.cc +177 -0
- data/src/core/lib/iomgr/exec_ctx.h +35 -13
- data/src/core/lib/iomgr/{executor.c → executor.cc} +34 -35
- data/src/core/lib/iomgr/executor.h +12 -4
- data/src/core/lib/iomgr/{fork_posix.c → fork_posix.cc} +0 -0
- data/src/core/lib/iomgr/{fork_windows.c → fork_windows.cc} +0 -0
- data/src/core/lib/iomgr/gethostname.h +9 -1
- data/src/core/lib/iomgr/{gethostname_fallback.c → gethostname_fallback.cc} +2 -1
- data/src/core/lib/iomgr/{gethostname_host_name_max.c → gethostname_host_name_max.cc} +4 -3
- data/src/core/lib/iomgr/{gethostname_sysconf.c → gethostname_sysconf.cc} +3 -2
- data/src/core/lib/iomgr/{iocp_windows.c → iocp_windows.cc} +23 -25
- data/src/core/lib/iomgr/iocp_windows.h +17 -3
- data/src/core/lib/iomgr/{iomgr.c → iomgr.cc} +25 -19
- data/src/core/lib/iomgr/iomgr.h +11 -3
- data/src/core/lib/iomgr/iomgr_internal.h +13 -5
- data/src/core/lib/iomgr/{iomgr_posix.c → iomgr_posix.cc} +0 -1
- data/src/core/lib/iomgr/{iomgr_uv.c → iomgr_uv.cc} +1 -1
- data/src/core/lib/iomgr/iomgr_uv.h +8 -0
- data/src/core/lib/iomgr/{iomgr_windows.c → iomgr_windows.cc} +0 -0
- data/src/core/lib/iomgr/{is_epollexclusive_available.c → is_epollexclusive_available.cc} +1 -1
- data/src/core/lib/iomgr/is_epollexclusive_available.h +8 -0
- data/src/core/lib/iomgr/{load_file.c → load_file.cc} +12 -12
- data/src/core/lib/iomgr/load_file.h +2 -2
- data/src/core/lib/iomgr/{lockfree_event.c → lockfree_event.cc} +76 -68
- data/src/core/lib/iomgr/lockfree_event.h +30 -11
- data/src/core/lib/iomgr/{network_status_tracker.c → network_status_tracker.cc} +3 -2
- data/src/core/lib/iomgr/network_status_tracker.h +2 -2
- data/src/core/lib/iomgr/{polling_entity.c → polling_entity.cc} +18 -18
- data/src/core/lib/iomgr/polling_entity.h +21 -13
- data/src/core/lib/iomgr/pollset.h +17 -11
- data/src/core/lib/iomgr/pollset_set.h +23 -15
- data/src/core/lib/iomgr/{pollset_set_uv.c → pollset_set_uv.cc} +0 -0
- data/src/core/lib/iomgr/{pollset_set_windows.c → pollset_set_windows.cc} +0 -0
- data/src/core/lib/iomgr/{pollset_uv.c → pollset_uv.cc} +31 -29
- data/src/core/lib/iomgr/pollset_uv.h +8 -0
- data/src/core/lib/iomgr/{pollset_windows.c → pollset_windows.cc} +24 -24
- data/src/core/lib/iomgr/pollset_windows.h +17 -4
- data/src/core/lib/iomgr/port.h +10 -0
- data/src/core/lib/iomgr/resolve_address.h +18 -10
- data/src/core/lib/iomgr/{resolve_address_posix.c → resolve_address_posix.cc} +40 -40
- data/src/core/lib/iomgr/{resolve_address_uv.c → resolve_address_uv.cc} +61 -56
- data/src/core/lib/iomgr/{resolve_address_windows.c → resolve_address_windows.cc} +36 -34
- data/src/core/lib/iomgr/{resource_quota.c → resource_quota.cc} +209 -180
- data/src/core/lib/iomgr/resource_quota.h +45 -37
- data/src/core/lib/iomgr/{sockaddr_utils.c → sockaddr_utils.cc} +61 -61
- data/src/core/lib/iomgr/sockaddr_utils.h +23 -15
- data/src/core/lib/iomgr/sockaddr_windows.h +6 -0
- data/src/core/lib/iomgr/{socket_factory_posix.c → socket_factory_posix.cc} +20 -20
- data/src/core/lib/iomgr/socket_factory_posix.h +15 -15
- data/src/core/lib/iomgr/{socket_mutator.c → socket_mutator.cc} +18 -18
- data/src/core/lib/iomgr/socket_mutator.h +11 -11
- data/src/core/lib/iomgr/socket_utils.h +9 -1
- data/src/core/lib/iomgr/{socket_utils_common_posix.c → socket_utils_common_posix.cc} +28 -28
- data/src/core/lib/iomgr/{socket_utils_linux.c → socket_utils_linux.cc} +3 -3
- data/src/core/lib/iomgr/{socket_utils_posix.c → socket_utils_posix.cc} +3 -3
- data/src/core/lib/iomgr/socket_utils_posix.h +26 -18
- data/src/core/lib/iomgr/{socket_utils_uv.c → socket_utils_uv.cc} +1 -1
- data/src/core/lib/iomgr/{socket_utils_windows.c → socket_utils_windows.cc} +2 -2
- data/src/core/lib/iomgr/{socket_windows.c → socket_windows.cc} +18 -18
- data/src/core/lib/iomgr/socket_windows.h +26 -13
- data/src/core/lib/iomgr/tcp_client.h +14 -6
- data/src/core/lib/iomgr/{tcp_client_posix.c → tcp_client_posix.cc} +69 -70
- data/src/core/lib/iomgr/tcp_client_posix.h +11 -3
- data/src/core/lib/iomgr/{tcp_client_uv.c → tcp_client_uv.cc} +47 -48
- data/src/core/lib/iomgr/{tcp_client_windows.c → tcp_client_windows.cc} +46 -44
- data/src/core/lib/iomgr/{tcp_posix.c → tcp_posix.cc} +198 -175
- data/src/core/lib/iomgr/tcp_posix.h +15 -7
- data/src/core/lib/iomgr/tcp_server.h +31 -23
- data/src/core/lib/iomgr/{tcp_server_posix.c → tcp_server_posix.cc} +78 -77
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +27 -19
- data/src/core/lib/iomgr/{tcp_server_utils_posix_common.c → tcp_server_utils_posix_common.cc} +27 -27
- data/src/core/lib/iomgr/{tcp_server_utils_posix_ifaddrs.c → tcp_server_utils_posix_ifaddrs.cc} +25 -25
- data/src/core/lib/iomgr/{tcp_server_utils_posix_noifaddrs.c → tcp_server_utils_posix_noifaddrs.cc} +2 -2
- data/src/core/lib/iomgr/{tcp_server_uv.c → tcp_server_uv.cc} +133 -105
- data/src/core/lib/iomgr/{tcp_server_windows.c → tcp_server_windows.cc} +81 -77
- data/src/core/lib/iomgr/tcp_uv.cc +420 -0
- data/src/core/lib/iomgr/tcp_uv.h +18 -4
- data/src/core/lib/iomgr/{tcp_windows.c → tcp_windows.cc} +90 -79
- data/src/core/lib/iomgr/tcp_windows.h +17 -4
- data/src/core/lib/iomgr/{time_averaged_stats.c → time_averaged_stats.cc} +0 -0
- data/src/core/lib/iomgr/time_averaged_stats.h +8 -0
- data/src/core/lib/iomgr/timer.h +16 -9
- data/src/core/lib/iomgr/{timer_generic.c → timer_generic.cc} +130 -171
- data/src/core/lib/iomgr/timer_generic.h +4 -4
- data/src/core/lib/iomgr/{timer_heap.c → timer_heap.cc} +20 -21
- data/src/core/lib/iomgr/timer_heap.h +16 -8
- data/src/core/lib/iomgr/{timer_manager.c → timer_manager.cc} +54 -52
- data/src/core/lib/iomgr/timer_manager.h +8 -0
- data/src/core/lib/iomgr/{timer_uv.c → timer_uv.cc} +22 -24
- data/src/core/lib/iomgr/timer_uv.h +2 -2
- data/src/core/lib/iomgr/{udp_server.c → udp_server.cc} +75 -75
- data/src/core/lib/iomgr/udp_server.h +25 -17
- data/src/core/lib/iomgr/{unix_sockets_posix.c → unix_sockets_posix.cc} +22 -21
- data/src/core/lib/iomgr/unix_sockets_posix.h +14 -6
- data/src/core/lib/iomgr/{unix_sockets_posix_noop.c → unix_sockets_posix_noop.cc} +5 -5
- data/src/core/lib/iomgr/{wakeup_fd_cv.c → wakeup_fd_cv.cc} +2 -2
- data/src/core/lib/iomgr/wakeup_fd_cv.h +10 -0
- data/src/core/lib/iomgr/{wakeup_fd_eventfd.c → wakeup_fd_eventfd.cc} +0 -0
- data/src/core/lib/iomgr/{wakeup_fd_nospecial.c → wakeup_fd_nospecial.cc} +0 -0
- data/src/core/lib/iomgr/{wakeup_fd_pipe.c → wakeup_fd_pipe.cc} +1 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +9 -1
- data/src/core/lib/iomgr/{wakeup_fd_posix.c → wakeup_fd_posix.cc} +6 -7
- data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -0
- data/src/core/lib/json/{json.c → json.cc} +0 -0
- data/src/core/lib/json/json.h +8 -0
- data/src/core/lib/json/{json_reader.c → json_reader.cc} +18 -18
- data/src/core/lib/json/json_reader.h +26 -18
- data/src/core/lib/json/{json_string.c → json_string.cc} +57 -57
- data/src/core/lib/json/{json_writer.c → json_writer.cc} +20 -20
- data/src/core/lib/json/json_writer.h +23 -15
- data/src/core/lib/profiling/{basic_timers.c → basic_timers.cc} +34 -34
- data/src/core/lib/profiling/{stap_timers.c → stap_timers.cc} +5 -5
- data/src/core/lib/profiling/timers.h +6 -6
- data/src/core/lib/security/context/{security_context.c → security_context.cc} +98 -95
- data/src/core/lib/security/context/security_context.h +27 -29
- data/src/core/lib/security/credentials/composite/{composite_credentials.c → composite_credentials.cc} +79 -73
- data/src/core/lib/security/credentials/composite/composite_credentials.h +17 -9
- data/src/core/lib/security/credentials/{credentials.c → credentials.cc} +97 -92
- data/src/core/lib/security/credentials/credentials.h +83 -75
- data/src/core/lib/security/credentials/{credentials_metadata.c → credentials_metadata.cc} +7 -6
- data/src/core/lib/security/credentials/fake/{fake_credentials.c → fake_credentials.cc} +39 -36
- data/src/core/lib/security/credentials/fake/fake_credentials.h +13 -5
- data/src/core/lib/security/credentials/google_default/{credentials_generic.c → credentials_generic.cc} +5 -5
- data/src/core/lib/security/credentials/google_default/{google_default_credentials.c → google_default_credentials.cc} +55 -55
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +9 -1
- data/src/core/lib/security/credentials/iam/{iam_credentials.c → iam_credentials.cc} +19 -18
- data/src/core/lib/security/credentials/jwt/{json_token.c → json_token.cc} +80 -75
- data/src/core/lib/security/credentials/jwt/json_token.h +23 -15
- data/src/core/lib/security/credentials/jwt/{jwt_credentials.c → jwt_credentials.cc} +45 -41
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -3
- data/src/core/lib/security/credentials/jwt/{jwt_verifier.c → jwt_verifier.cc} +262 -252
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +38 -30
- data/src/core/lib/security/credentials/oauth2/{oauth2_credentials.c → oauth2_credentials.cc} +138 -141
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +30 -22
- data/src/core/lib/security/credentials/plugin/{plugin_credentials.c → plugin_credentials.cc} +52 -53
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +7 -7
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +344 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +27 -0
- data/src/core/lib/security/transport/auth_filters.h +16 -0
- data/src/core/lib/security/transport/{client_auth_filter.c → client_auth_filter.cc} +127 -115
- data/src/core/lib/security/transport/{lb_targets_info.c → lb_targets_info.cc} +16 -13
- data/src/core/lib/security/transport/lb_targets_info.h +11 -3
- data/src/core/lib/security/transport/{secure_endpoint.c → secure_endpoint.cc} +84 -76
- data/src/core/lib/security/transport/secure_endpoint.h +13 -5
- data/src/core/lib/security/transport/security_connector.cc +1121 -0
- data/src/core/lib/security/transport/security_connector.h +97 -79
- data/src/core/lib/security/transport/{security_handshaker.c → security_handshaker.cc} +139 -132
- data/src/core/lib/security/transport/security_handshaker.h +11 -3
- data/src/core/lib/security/transport/{server_auth_filter.c → server_auth_filter.cc} +68 -68
- data/src/core/lib/security/transport/{tsi_error.c → tsi_error.cc} +1 -1
- data/src/core/lib/security/transport/tsi_error.h +9 -1
- data/src/core/lib/security/util/{json_util.c → json_util.cc} +11 -11
- data/src/core/lib/security/util/json_util.h +12 -4
- data/src/core/lib/slice/{b64.c → b64.cc} +15 -15
- data/src/core/lib/slice/b64.h +12 -4
- data/src/core/lib/slice/{percent_encoding.c → percent_encoding.cc} +15 -15
- data/src/core/lib/slice/percent_encoding.h +11 -3
- data/src/core/lib/slice/{slice.c → slice.cc} +64 -64
- data/src/core/lib/slice/{slice_buffer.c → slice_buffer.cc} +38 -38
- data/src/core/lib/slice/{slice_hash_table.c → slice_hash_table.cc} +7 -7
- data/src/core/lib/slice/slice_hash_table.h +19 -11
- data/src/core/lib/slice/{slice_intern.c → slice_intern.cc} +35 -34
- data/src/core/lib/slice/slice_internal.h +17 -6
- data/src/core/lib/slice/{slice_string_helpers.c → slice_string_helpers.cc} +9 -9
- data/src/core/lib/slice/slice_string_helpers.h +3 -3
- data/src/core/lib/support/abstract.h +29 -0
- data/src/core/lib/support/{alloc.c → alloc.cc} +22 -22
- data/src/core/lib/support/{arena.c → arena.cc} +12 -12
- data/src/core/lib/support/arena.h +11 -3
- data/src/core/lib/support/{atm.c → atm.cc} +1 -1
- data/src/core/lib/support/{avl.c → avl.cc} +71 -70
- data/src/core/lib/support/{cmdline.c → cmdline.cc} +62 -62
- data/src/core/lib/support/{cpu_iphone.c → cpu_iphone.cc} +2 -0
- data/src/core/lib/support/{cpu_linux.c → cpu_linux.cc} +10 -0
- data/src/core/lib/support/{cpu_posix.c → cpu_posix.cc} +27 -4
- data/src/core/lib/support/{cpu_windows.c → cpu_windows.cc} +1 -0
- data/src/core/lib/support/env.h +3 -3
- data/src/core/lib/support/{env_linux.c → env_linux.cc} +11 -11
- data/src/core/lib/support/{env_posix.c → env_posix.cc} +4 -4
- data/src/core/lib/support/{env_windows.c → env_windows.cc} +5 -5
- data/src/core/lib/support/{fork.c → fork.cc} +2 -2
- data/src/core/lib/support/{histogram.c → histogram.cc} +25 -26
- data/src/core/lib/support/{host_port.c → host_port.cc} +16 -16
- data/src/core/lib/support/{log.c → log.cc} +8 -8
- data/src/core/lib/support/{log_android.c → log_android.cc} +7 -7
- data/src/core/lib/support/{log_linux.c → log_linux.cc} +8 -8
- data/src/core/lib/support/{log_posix.c → log_posix.cc} +9 -10
- data/src/core/lib/support/{log_windows.c → log_windows.cc} +7 -7
- data/src/core/lib/support/manual_constructor.h +211 -0
- data/src/core/lib/support/memory.h +41 -0
- data/src/core/lib/support/mpscq.cc +114 -0
- data/src/core/lib/support/mpscq.h +45 -7
- data/src/core/lib/support/{murmur_hash.c → murmur_hash.cc} +9 -12
- data/src/core/lib/support/murmur_hash.h +9 -1
- data/src/core/lib/support/spinlock.h +8 -1
- data/src/core/lib/support/{string.c → string.cc} +56 -55
- data/src/core/lib/support/string.h +21 -21
- data/src/core/lib/support/{string_posix.c → string_posix.cc} +5 -4
- data/src/core/lib/support/{string_util_windows.c → string_util_windows.cc} +9 -6
- data/src/core/lib/support/{string_windows.c → string_windows.cc} +3 -2
- data/src/core/lib/support/string_windows.h +8 -0
- data/src/core/lib/support/{subprocess_posix.c → subprocess_posix.cc} +13 -13
- data/src/core/lib/support/{subprocess_windows.c → subprocess_windows.cc} +9 -9
- data/src/core/lib/support/{sync.c → sync.cc} +22 -22
- data/src/core/lib/support/{sync_posix.c → sync_posix.cc} +6 -2
- data/src/core/lib/support/{sync_windows.c → sync_windows.cc} +14 -14
- data/src/core/lib/support/{thd.c → thd.cc} +0 -0
- data/src/core/lib/support/{thd_posix.c → thd_posix.cc} +10 -10
- data/src/core/lib/support/{thd_windows.c → thd_windows.cc} +10 -10
- data/src/core/lib/support/{time.c → time.cc} +0 -0
- data/src/core/lib/support/{time_posix.c → time_posix.cc} +5 -6
- data/src/core/lib/support/{time_precise.c → time_precise.cc} +6 -4
- data/src/core/lib/support/time_precise.h +9 -1
- data/src/core/lib/support/{time_windows.c → time_windows.cc} +2 -3
- data/src/core/lib/support/{tls_pthread.c → tls_pthread.cc} +2 -2
- data/src/core/lib/support/tmpfile.h +1 -1
- data/src/core/lib/support/{tmpfile_msys.c → tmpfile_msys.cc} +2 -2
- data/src/core/lib/support/{tmpfile_posix.c → tmpfile_posix.cc} +7 -7
- data/src/core/lib/support/{tmpfile_windows.c → tmpfile_windows.cc} +2 -2
- data/src/core/lib/support/{wrap_memcpy.c → wrap_memcpy.cc} +4 -2
- data/src/core/lib/surface/{alarm.c → alarm.cc} +32 -31
- data/src/core/lib/surface/alarm_internal.h +10 -2
- data/src/core/lib/surface/{api_trace.c → api_trace.cc} +1 -1
- data/src/core/lib/surface/api_trace.h +2 -2
- data/src/core/lib/surface/{byte_buffer.c → byte_buffer.cc} +13 -13
- data/src/core/lib/surface/{byte_buffer_reader.c → byte_buffer_reader.cc} +9 -9
- data/src/core/lib/surface/{call.c → call.cc} +379 -372
- data/src/core/lib/surface/call.h +37 -38
- data/src/core/lib/surface/{call_details.c → call_details.cc} +0 -0
- data/src/core/lib/surface/{call_log_batch.c → call_log_batch.cc} +13 -11
- data/src/core/lib/surface/call_test_only.h +5 -5
- data/src/core/lib/surface/{channel.c → channel.cc} +94 -95
- data/src/core/lib/surface/channel.h +29 -21
- data/src/core/lib/surface/{channel_init.c → channel_init.cc} +13 -13
- data/src/core/lib/surface/channel_init.h +6 -6
- data/src/core/lib/surface/{channel_ping.c → channel_ping.cc} +12 -12
- data/src/core/lib/surface/{channel_stack_type.c → channel_stack_type.cc} +1 -1
- data/src/core/lib/surface/channel_stack_type.h +9 -1
- data/src/core/lib/surface/{completion_queue.c → completion_queue.cc} +416 -379
- data/src/core/lib/surface/completion_queue.h +29 -29
- data/src/core/lib/surface/{completion_queue_factory.c → completion_queue_factory.cc} +1 -1
- data/src/core/lib/surface/completion_queue_factory.h +8 -0
- data/src/core/lib/surface/{event_string.c → event_string.cc} +9 -9
- data/src/core/lib/surface/event_string.h +9 -1
- data/src/core/lib/surface/{init.c → init.cc} +16 -39
- data/src/core/lib/surface/init.h +8 -0
- data/src/core/lib/surface/{init_secure.c → init_secure.cc} +12 -25
- data/src/core/lib/surface/lame_client.cc +38 -40
- data/src/core/lib/surface/lame_client.h +8 -0
- data/src/core/lib/surface/{metadata_array.c → metadata_array.cc} +0 -0
- data/src/core/lib/surface/{server.c → server.cc} +340 -404
- data/src/core/lib/surface/server.h +22 -14
- data/src/core/lib/surface/{validate_metadata.c → validate_metadata.cc} +10 -9
- data/src/core/lib/surface/validate_metadata.h +10 -2
- data/src/core/lib/surface/{version.c → version.cc} +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +84 -0
- data/src/core/lib/transport/bdp_estimator.h +67 -42
- data/src/core/lib/transport/{byte_stream.c → byte_stream.cc} +51 -51
- data/src/core/lib/transport/byte_stream.h +41 -33
- data/src/core/lib/transport/{connectivity_state.c → connectivity_state.cc} +36 -40
- data/src/core/lib/transport/connectivity_state.h +29 -21
- data/src/core/lib/transport/{error_utils.c → error_utils.cc} +26 -22
- data/src/core/lib/transport/error_utils.h +18 -6
- data/src/core/lib/transport/{metadata.c → metadata.cc} +92 -88
- data/src/core/lib/transport/metadata.h +22 -20
- data/src/core/lib/transport/{metadata_batch.c → metadata_batch.cc} +78 -79
- data/src/core/lib/transport/metadata_batch.h +46 -45
- data/src/core/lib/transport/pid_controller.cc +48 -0
- data/src/core/lib/transport/pid_controller.h +84 -32
- data/src/core/lib/transport/{service_config.c → service_config.cc} +66 -48
- data/src/core/lib/transport/service_config.h +11 -2
- data/src/core/lib/transport/{static_metadata.c → static_metadata.cc} +2 -2
- data/src/core/lib/transport/static_metadata.h +30 -23
- data/src/core/lib/transport/{status_conversion.c → status_conversion.cc} +4 -3
- data/src/core/lib/transport/status_conversion.h +12 -2
- data/src/core/lib/transport/{timeout_encoding.c → timeout_encoding.cc} +28 -61
- data/src/core/lib/transport/timeout_encoding.h +11 -2
- data/src/core/lib/transport/{transport.c → transport.cc} +79 -79
- data/src/core/lib/transport/transport.h +78 -80
- data/src/core/lib/transport/transport_impl.h +27 -19
- data/src/core/lib/transport/{transport_op_string.c → transport_op_string.cc} +32 -30
- data/src/core/plugin_registry/{grpc_plugin_registry.c → grpc_plugin_registry.cc} +34 -38
- data/src/core/tsi/{fake_transport_security.c → fake_transport_security.cc} +141 -132
- data/src/core/tsi/fake_transport_security.h +5 -5
- data/src/core/tsi/{gts_transport_security.c → gts_transport_security.cc} +4 -4
- data/src/core/tsi/gts_transport_security.h +11 -3
- data/src/core/tsi/{ssl_transport_security.c → ssl_transport_security.cc} +309 -300
- data/src/core/tsi/ssl_transport_security.h +25 -25
- data/src/core/tsi/ssl_types.h +8 -0
- data/src/core/tsi/{transport_security.c → transport_security.cc} +94 -87
- data/src/core/tsi/transport_security.h +55 -55
- data/src/core/tsi/{transport_security_adapter.c → transport_security_adapter.cc} +58 -55
- data/src/core/tsi/transport_security_adapter.h +2 -2
- data/src/core/tsi/{transport_security_grpc.c → transport_security_grpc.cc} +21 -21
- data/src/core/tsi/transport_security_grpc.h +19 -19
- data/src/core/tsi/transport_security_interface.h +41 -41
- data/src/ruby/ext/grpc/extconf.rb +4 -2
- data/src/ruby/ext/grpc/rb_byte_buffer.c +5 -5
- data/src/ruby/ext/grpc/rb_byte_buffer.h +2 -2
- data/src/ruby/ext/grpc/rb_call.c +41 -42
- data/src/ruby/ext/grpc/rb_call.h +6 -6
- data/src/ruby/ext/grpc/rb_call_credentials.c +30 -30
- data/src/ruby/ext/grpc/rb_channel.c +87 -87
- data/src/ruby/ext/grpc/rb_channel_credentials.c +23 -23
- data/src/ruby/ext/grpc/rb_completion_queue.c +11 -11
- data/src/ruby/ext/grpc/rb_completion_queue.h +3 -3
- data/src/ruby/ext/grpc/rb_compression_options.c +20 -20
- data/src/ruby/ext/grpc/rb_event_thread.c +14 -14
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +8 -8
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -58
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +242 -306
- data/src/ruby/ext/grpc/rb_server.c +23 -23
- data/src/ruby/ext/grpc/rb_server_credentials.c +13 -13
- data/src/ruby/lib/grpc/generic/rpc_server.rb +25 -12
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/checker.rb +14 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +29 -0
- data/third_party/cares/config_freebsd/ares_config.h +502 -0
- data/third_party/cares/config_openbsd/ares_config.h +502 -0
- metadata +302 -328
- data/src/core/ext/census/aggregation.h +0 -51
- data/src/core/ext/census/base_resources.c +0 -56
- data/src/core/ext/census/base_resources.h +0 -24
- data/src/core/ext/census/census_interface.h +0 -61
- data/src/core/ext/census/census_rpc_stats.h +0 -86
- data/src/core/ext/census/context.c +0 -496
- data/src/core/ext/census/gen/census.pb.c +0 -161
- data/src/core/ext/census/gen/census.pb.h +0 -280
- data/src/core/ext/census/gen/trace_context.pb.c +0 -39
- data/src/core/ext/census/gen/trace_context.pb.h +0 -78
- data/src/core/ext/census/grpc_filter.c +0 -196
- data/src/core/ext/census/grpc_plugin.c +0 -70
- data/src/core/ext/census/initialize.c +0 -51
- data/src/core/ext/census/intrusive_hash_map.c +0 -305
- data/src/core/ext/census/intrusive_hash_map.h +0 -152
- data/src/core/ext/census/intrusive_hash_map_internal.h +0 -48
- data/src/core/ext/census/mlog.c +0 -586
- data/src/core/ext/census/mlog.h +0 -80
- data/src/core/ext/census/operation.c +0 -48
- data/src/core/ext/census/placeholders.c +0 -49
- data/src/core/ext/census/resource.c +0 -303
- data/src/core/ext/census/resource.h +0 -48
- data/src/core/ext/census/rpc_metric_id.h +0 -36
- data/src/core/ext/census/trace_context.c +0 -71
- data/src/core/ext/census/trace_context.h +0 -56
- data/src/core/ext/census/trace_label.h +0 -46
- data/src/core/ext/census/trace_propagation.h +0 -48
- data/src/core/ext/census/trace_status.h +0 -30
- data/src/core/ext/census/trace_string.h +0 -35
- data/src/core/ext/census/tracing.c +0 -55
- data/src/core/ext/census/tracing.h +0 -109
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +0 -714
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +0 -924
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +0 -60
- data/src/core/ext/transport/chttp2/transport/flow_control.c +0 -502
- data/src/core/ext/transport/chttp2/transport/writing.c +0 -534
- data/src/core/lib/debug/trace.c +0 -146
- data/src/core/lib/iomgr/closure.c +0 -219
- data/src/core/lib/iomgr/ev_epollex_linux.c +0 -1461
- data/src/core/lib/iomgr/ev_posix.c +0 -266
- data/src/core/lib/iomgr/exec_ctx.c +0 -113
- data/src/core/lib/iomgr/tcp_uv.c +0 -381
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +0 -194
- data/src/core/lib/security/transport/security_connector.c +0 -914
- data/src/core/lib/support/backoff.c +0 -72
- data/src/core/lib/support/backoff.h +0 -56
- data/src/core/lib/support/mpscq.c +0 -79
- data/src/core/lib/support/stack_lockfree.c +0 -137
- data/src/core/lib/support/stack_lockfree.h +0 -38
- data/src/core/lib/transport/bdp_estimator.c +0 -110
- data/src/core/lib/transport/pid_controller.c +0 -63
@@ -33,16 +33,16 @@ extern "C" {
|
|
33
33
|
No cryptography is performed in these objects. They just simulate handshake
|
34
34
|
messages going back and forth for the handshaker and do some framing on
|
35
35
|
cleartext data for the protector. */
|
36
|
-
tsi_handshaker
|
36
|
+
tsi_handshaker* tsi_create_fake_handshaker(int is_client);
|
37
37
|
|
38
38
|
/* Creates a protector directly without going through the handshake phase. */
|
39
|
-
tsi_frame_protector
|
40
|
-
size_t
|
39
|
+
tsi_frame_protector* tsi_create_fake_frame_protector(
|
40
|
+
size_t* max_protected_frame_size);
|
41
41
|
|
42
42
|
/* Creates a zero-copy protector directly without going through the handshake
|
43
43
|
* phase. */
|
44
|
-
tsi_zero_copy_grpc_protector
|
45
|
-
size_t
|
44
|
+
tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector(
|
45
|
+
size_t* max_protected_frame_size);
|
46
46
|
|
47
47
|
#ifdef __cplusplus
|
48
48
|
}
|
@@ -22,16 +22,16 @@
|
|
22
22
|
|
23
23
|
static gts_shared_resource g_gts_resource;
|
24
24
|
|
25
|
-
gts_shared_resource
|
25
|
+
gts_shared_resource* gts_get_shared_resource(void) { return &g_gts_resource; }
|
26
26
|
|
27
|
-
void grpc_tsi_gts_init() {
|
27
|
+
extern "C" void grpc_tsi_gts_init() {
|
28
28
|
memset(&g_gts_resource, 0, sizeof(gts_shared_resource));
|
29
29
|
gpr_mu_init(&g_gts_resource.mu);
|
30
30
|
}
|
31
31
|
|
32
|
-
void grpc_tsi_gts_shutdown() {
|
32
|
+
extern "C" void grpc_tsi_gts_shutdown() {
|
33
33
|
gpr_mu_destroy(&g_gts_resource.mu);
|
34
|
-
if (g_gts_resource.cq ==
|
34
|
+
if (g_gts_resource.cq == nullptr) {
|
35
35
|
return;
|
36
36
|
}
|
37
37
|
grpc_completion_queue_destroy(g_gts_resource.cq);
|
@@ -23,15 +23,23 @@
|
|
23
23
|
#include <grpc/support/sync.h>
|
24
24
|
#include <grpc/support/thd.h>
|
25
25
|
|
26
|
+
#ifdef __cplusplus
|
27
|
+
extern "C" {
|
28
|
+
#endif
|
29
|
+
|
26
30
|
typedef struct gts_shared_resource {
|
27
31
|
gpr_thd_id thread_id;
|
28
|
-
grpc_channel
|
29
|
-
grpc_completion_queue
|
32
|
+
grpc_channel* channel;
|
33
|
+
grpc_completion_queue* cq;
|
30
34
|
gpr_mu mu;
|
31
35
|
} gts_shared_resource;
|
32
36
|
|
33
37
|
/* This method returns the address of gts_shared_resource object shared by all
|
34
38
|
* TSI handshakes. */
|
35
|
-
gts_shared_resource
|
39
|
+
gts_shared_resource* gts_get_shared_resource(void);
|
40
|
+
|
41
|
+
#ifdef __cplusplus
|
42
|
+
}
|
43
|
+
#endif
|
36
44
|
|
37
45
|
#endif /* GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H */
|
@@ -39,12 +39,14 @@
|
|
39
39
|
#include <grpc/support/thd.h>
|
40
40
|
#include <grpc/support/useful.h>
|
41
41
|
|
42
|
+
extern "C" {
|
42
43
|
#include <openssl/bio.h>
|
43
44
|
#include <openssl/crypto.h> /* For OPENSSL_free */
|
44
45
|
#include <openssl/err.h>
|
45
46
|
#include <openssl/ssl.h>
|
46
47
|
#include <openssl/x509.h>
|
47
48
|
#include <openssl/x509v3.h>
|
49
|
+
}
|
48
50
|
|
49
51
|
#include "src/core/tsi/ssl_types.h"
|
50
52
|
#include "src/core/tsi/transport_security.h"
|
@@ -68,14 +70,14 @@
|
|
68
70
|
/* --- Structure definitions. ---*/
|
69
71
|
|
70
72
|
struct tsi_ssl_handshaker_factory {
|
71
|
-
const tsi_ssl_handshaker_factory_vtable
|
73
|
+
const tsi_ssl_handshaker_factory_vtable* vtable;
|
72
74
|
gpr_refcount refcount;
|
73
75
|
};
|
74
76
|
|
75
77
|
struct tsi_ssl_client_handshaker_factory {
|
76
78
|
tsi_ssl_handshaker_factory base;
|
77
|
-
SSL_CTX
|
78
|
-
unsigned char
|
79
|
+
SSL_CTX* ssl_context;
|
80
|
+
unsigned char* alpn_protocol_list;
|
79
81
|
size_t alpn_protocol_list_length;
|
80
82
|
};
|
81
83
|
|
@@ -84,28 +86,28 @@ struct tsi_ssl_server_handshaker_factory {
|
|
84
86
|
The tsi_peer array contains the subject names of the server certificates
|
85
87
|
associated with the contexts at the same index. */
|
86
88
|
tsi_ssl_handshaker_factory base;
|
87
|
-
SSL_CTX
|
88
|
-
tsi_peer
|
89
|
+
SSL_CTX** ssl_contexts;
|
90
|
+
tsi_peer* ssl_context_x509_subject_names;
|
89
91
|
size_t ssl_context_count;
|
90
|
-
unsigned char
|
92
|
+
unsigned char* alpn_protocol_list;
|
91
93
|
size_t alpn_protocol_list_length;
|
92
94
|
};
|
93
95
|
|
94
96
|
typedef struct {
|
95
97
|
tsi_handshaker base;
|
96
|
-
SSL
|
97
|
-
BIO
|
98
|
-
BIO
|
98
|
+
SSL* ssl;
|
99
|
+
BIO* into_ssl;
|
100
|
+
BIO* from_ssl;
|
99
101
|
tsi_result result;
|
100
|
-
tsi_ssl_handshaker_factory
|
102
|
+
tsi_ssl_handshaker_factory* factory_ref;
|
101
103
|
} tsi_ssl_handshaker;
|
102
104
|
|
103
105
|
typedef struct {
|
104
106
|
tsi_frame_protector base;
|
105
|
-
SSL
|
106
|
-
BIO
|
107
|
-
BIO
|
108
|
-
unsigned char
|
107
|
+
SSL* ssl;
|
108
|
+
BIO* into_ssl;
|
109
|
+
BIO* from_ssl;
|
110
|
+
unsigned char* buffer;
|
109
111
|
size_t buffer_size;
|
110
112
|
size_t buffer_offset;
|
111
113
|
} tsi_ssl_frame_protector;
|
@@ -113,9 +115,9 @@ typedef struct {
|
|
113
115
|
/* --- Library Initialization. ---*/
|
114
116
|
|
115
117
|
static gpr_once init_openssl_once = GPR_ONCE_INIT;
|
116
|
-
static gpr_mu
|
118
|
+
static gpr_mu* openssl_mutexes = nullptr;
|
117
119
|
|
118
|
-
static void openssl_locking_cb(int mode, int type, const char
|
120
|
+
static void openssl_locking_cb(int mode, int type, const char* file, int line) {
|
119
121
|
if (mode & CRYPTO_LOCK) {
|
120
122
|
gpr_mu_lock(&openssl_mutexes[type]);
|
121
123
|
} else {
|
@@ -135,7 +137,7 @@ static void init_openssl(void) {
|
|
135
137
|
OpenSSL_add_all_algorithms();
|
136
138
|
num_locks = CRYPTO_num_locks();
|
137
139
|
GPR_ASSERT(num_locks > 0);
|
138
|
-
openssl_mutexes = gpr_malloc((size_t)num_locks * sizeof(gpr_mu));
|
140
|
+
openssl_mutexes = (gpr_mu*)gpr_malloc((size_t)num_locks * sizeof(gpr_mu));
|
139
141
|
for (i = 0; i < CRYPTO_num_locks(); i++) {
|
140
142
|
gpr_mu_init(&openssl_mutexes[i]);
|
141
143
|
}
|
@@ -145,7 +147,7 @@ static void init_openssl(void) {
|
|
145
147
|
|
146
148
|
/* --- Ssl utils. ---*/
|
147
149
|
|
148
|
-
static const char
|
150
|
+
static const char* ssl_error_string(int error) {
|
149
151
|
switch (error) {
|
150
152
|
case SSL_ERROR_NONE:
|
151
153
|
return "SSL_ERROR_NONE";
|
@@ -171,16 +173,16 @@ static const char *ssl_error_string(int error) {
|
|
171
173
|
}
|
172
174
|
|
173
175
|
/* TODO(jboeuf): Remove when we are past the debugging phase with this code. */
|
174
|
-
static void ssl_log_where_info(const SSL
|
175
|
-
const char
|
176
|
-
if ((where & flag) &&
|
176
|
+
static void ssl_log_where_info(const SSL* ssl, int where, int flag,
|
177
|
+
const char* msg) {
|
178
|
+
if ((where & flag) && tsi_tracing_enabled.enabled()) {
|
177
179
|
gpr_log(GPR_INFO, "%20.20s - %30.30s - %5.10s", msg,
|
178
180
|
SSL_state_string_long(ssl), SSL_state_string(ssl));
|
179
181
|
}
|
180
182
|
}
|
181
183
|
|
182
184
|
/* Used for debugging. TODO(jboeuf): Remove when code is mature enough. */
|
183
|
-
static void ssl_info_callback(const SSL
|
185
|
+
static void ssl_info_callback(const SSL* ssl, int where, int ret) {
|
184
186
|
if (ret == 0) {
|
185
187
|
gpr_log(GPR_ERROR, "ssl_info_callback: error occured.\n");
|
186
188
|
return;
|
@@ -193,7 +195,7 @@ static void ssl_info_callback(const SSL *ssl, int where, int ret) {
|
|
193
195
|
|
194
196
|
/* Returns 1 if name looks like an IP address, 0 otherwise.
|
195
197
|
This is a very rough heuristic, and only handles IPv6 in hexadecimal form. */
|
196
|
-
static int looks_like_ip_address(const char
|
198
|
+
static int looks_like_ip_address(const char* name) {
|
197
199
|
size_t i;
|
198
200
|
size_t dot_count = 0;
|
199
201
|
size_t num_size = 0;
|
@@ -218,14 +220,14 @@ static int looks_like_ip_address(const char *name) {
|
|
218
220
|
}
|
219
221
|
|
220
222
|
/* Gets the subject CN from an X509 cert. */
|
221
|
-
static tsi_result ssl_get_x509_common_name(X509
|
222
|
-
size_t
|
223
|
+
static tsi_result ssl_get_x509_common_name(X509* cert, unsigned char** utf8,
|
224
|
+
size_t* utf8_size) {
|
223
225
|
int common_name_index = -1;
|
224
|
-
X509_NAME_ENTRY
|
225
|
-
ASN1_STRING
|
226
|
-
X509_NAME
|
226
|
+
X509_NAME_ENTRY* common_name_entry = nullptr;
|
227
|
+
ASN1_STRING* common_name_asn1 = nullptr;
|
228
|
+
X509_NAME* subject_name = X509_get_subject_name(cert);
|
227
229
|
int utf8_returned_size = 0;
|
228
|
-
if (subject_name ==
|
230
|
+
if (subject_name == nullptr) {
|
229
231
|
gpr_log(GPR_ERROR, "Could not get subject name from certificate.");
|
230
232
|
return TSI_NOT_FOUND;
|
231
233
|
}
|
@@ -237,12 +239,12 @@ static tsi_result ssl_get_x509_common_name(X509 *cert, unsigned char **utf8,
|
|
237
239
|
return TSI_NOT_FOUND;
|
238
240
|
}
|
239
241
|
common_name_entry = X509_NAME_get_entry(subject_name, common_name_index);
|
240
|
-
if (common_name_entry ==
|
242
|
+
if (common_name_entry == nullptr) {
|
241
243
|
gpr_log(GPR_ERROR, "Could not get common name entry from certificate.");
|
242
244
|
return TSI_INTERNAL_ERROR;
|
243
245
|
}
|
244
246
|
common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);
|
245
|
-
if (common_name_asn1 ==
|
247
|
+
if (common_name_asn1 == nullptr) {
|
246
248
|
gpr_log(GPR_ERROR,
|
247
249
|
"Could not get common name entry asn1 from certificate.");
|
248
250
|
return TSI_INTERNAL_ERROR;
|
@@ -258,14 +260,14 @@ static tsi_result ssl_get_x509_common_name(X509 *cert, unsigned char **utf8,
|
|
258
260
|
|
259
261
|
/* Gets the subject CN of an X509 cert as a tsi_peer_property. */
|
260
262
|
static tsi_result peer_property_from_x509_common_name(
|
261
|
-
X509
|
262
|
-
unsigned char
|
263
|
+
X509* cert, tsi_peer_property* property) {
|
264
|
+
unsigned char* common_name;
|
263
265
|
size_t common_name_size;
|
264
266
|
tsi_result result =
|
265
267
|
ssl_get_x509_common_name(cert, &common_name, &common_name_size);
|
266
268
|
if (result != TSI_OK) {
|
267
269
|
if (result == TSI_NOT_FOUND) {
|
268
|
-
common_name =
|
270
|
+
common_name = nullptr;
|
269
271
|
common_name_size = 0;
|
270
272
|
} else {
|
271
273
|
return result;
|
@@ -273,35 +275,34 @@ static tsi_result peer_property_from_x509_common_name(
|
|
273
275
|
}
|
274
276
|
result = tsi_construct_string_peer_property(
|
275
277
|
TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY,
|
276
|
-
common_name ==
|
278
|
+
common_name == nullptr ? "" : (const char*)common_name, common_name_size,
|
277
279
|
property);
|
278
280
|
OPENSSL_free(common_name);
|
279
281
|
return result;
|
280
282
|
}
|
281
283
|
|
282
284
|
/* Gets the X509 cert in PEM format as a tsi_peer_property. */
|
283
|
-
static tsi_result add_pem_certificate(X509
|
284
|
-
BIO
|
285
|
+
static tsi_result add_pem_certificate(X509* cert, tsi_peer_property* property) {
|
286
|
+
BIO* bio = BIO_new(BIO_s_mem());
|
285
287
|
if (!PEM_write_bio_X509(bio, cert)) {
|
286
288
|
BIO_free(bio);
|
287
289
|
return TSI_INTERNAL_ERROR;
|
288
290
|
}
|
289
|
-
char
|
291
|
+
char* contents;
|
290
292
|
long len = BIO_get_mem_data(bio, &contents);
|
291
293
|
if (len <= 0) {
|
292
294
|
BIO_free(bio);
|
293
295
|
return TSI_INTERNAL_ERROR;
|
294
296
|
}
|
295
297
|
tsi_result result = tsi_construct_string_peer_property(
|
296
|
-
TSI_X509_PEM_CERT_PROPERTY, (const char
|
297
|
-
property);
|
298
|
+
TSI_X509_PEM_CERT_PROPERTY, (const char*)contents, (size_t)len, property);
|
298
299
|
BIO_free(bio);
|
299
300
|
return result;
|
300
301
|
}
|
301
302
|
|
302
303
|
/* Gets the subject SANs from an X509 cert as a tsi_peer_property. */
|
303
304
|
static tsi_result add_subject_alt_names_properties_to_peer(
|
304
|
-
tsi_peer
|
305
|
+
tsi_peer* peer, GENERAL_NAMES* subject_alt_names,
|
305
306
|
size_t subject_alt_name_count) {
|
306
307
|
size_t i;
|
307
308
|
tsi_result result = TSI_OK;
|
@@ -310,11 +311,11 @@ static tsi_result add_subject_alt_names_properties_to_peer(
|
|
310
311
|
peer->property_count -= subject_alt_name_count;
|
311
312
|
|
312
313
|
for (i = 0; i < subject_alt_name_count; i++) {
|
313
|
-
GENERAL_NAME
|
314
|
+
GENERAL_NAME* subject_alt_name =
|
314
315
|
sk_GENERAL_NAME_value(subject_alt_names, TSI_SIZE_AS_SIZE(i));
|
315
316
|
/* Filter out the non-dns entries names. */
|
316
317
|
if (subject_alt_name->type == GEN_DNS) {
|
317
|
-
unsigned char
|
318
|
+
unsigned char* name = nullptr;
|
318
319
|
int name_size;
|
319
320
|
name_size = ASN1_STRING_to_UTF8(&name, subject_alt_name->d.dNSName);
|
320
321
|
if (name_size < 0) {
|
@@ -323,7 +324,7 @@ static tsi_result add_subject_alt_names_properties_to_peer(
|
|
323
324
|
break;
|
324
325
|
}
|
325
326
|
result = tsi_construct_string_peer_property(
|
326
|
-
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, (const char
|
327
|
+
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, (const char*)name,
|
327
328
|
(size_t)name_size, &peer->properties[peer->property_count++]);
|
328
329
|
OPENSSL_free(name);
|
329
330
|
} else if (subject_alt_name->type == GEN_IPADD) {
|
@@ -339,9 +340,9 @@ static tsi_result add_subject_alt_names_properties_to_peer(
|
|
339
340
|
result = TSI_INTERNAL_ERROR;
|
340
341
|
break;
|
341
342
|
}
|
342
|
-
const char
|
343
|
+
const char* name = inet_ntop(af, subject_alt_name->d.iPAddress->data,
|
343
344
|
ntop_buf, INET6_ADDRSTRLEN);
|
344
|
-
if (name ==
|
345
|
+
if (name == nullptr) {
|
345
346
|
gpr_log(GPR_ERROR, "Could not get IP string from asn1 octet.");
|
346
347
|
result = TSI_INTERNAL_ERROR;
|
347
348
|
break;
|
@@ -357,12 +358,12 @@ static tsi_result add_subject_alt_names_properties_to_peer(
|
|
357
358
|
}
|
358
359
|
|
359
360
|
/* Gets information about the peer's X509 cert as a tsi_peer object. */
|
360
|
-
static tsi_result peer_from_x509(X509
|
361
|
-
tsi_peer
|
361
|
+
static tsi_result peer_from_x509(X509* cert, int include_certificate_type,
|
362
|
+
tsi_peer* peer) {
|
362
363
|
/* TODO(jboeuf): Maybe add more properties. */
|
363
|
-
GENERAL_NAMES
|
364
|
-
|
365
|
-
int subject_alt_name_count = (subject_alt_names !=
|
364
|
+
GENERAL_NAMES* subject_alt_names = (GENERAL_NAMES*)X509_get_ext_d2i(
|
365
|
+
cert, NID_subject_alt_name, nullptr, nullptr);
|
366
|
+
int subject_alt_name_count = (subject_alt_names != nullptr)
|
366
367
|
? (int)sk_GENERAL_NAME_num(subject_alt_names)
|
367
368
|
: 0;
|
368
369
|
size_t property_count;
|
@@ -395,7 +396,7 @@ static tsi_result peer_from_x509(X509 *cert, int include_certificate_type,
|
|
395
396
|
}
|
396
397
|
} while (0);
|
397
398
|
|
398
|
-
if (subject_alt_names !=
|
399
|
+
if (subject_alt_names != nullptr) {
|
399
400
|
sk_GENERAL_NAME_pop_free(subject_alt_names, GENERAL_NAME_free);
|
400
401
|
}
|
401
402
|
if (result != TSI_OK) tsi_peer_destruct(peer);
|
@@ -413,8 +414,8 @@ static void log_ssl_error_stack(void) {
|
|
413
414
|
}
|
414
415
|
|
415
416
|
/* Performs an SSL_read and handle errors. */
|
416
|
-
static tsi_result do_ssl_read(SSL
|
417
|
-
size_t
|
417
|
+
static tsi_result do_ssl_read(SSL* ssl, unsigned char* unprotected_bytes,
|
418
|
+
size_t* unprotected_bytes_size) {
|
418
419
|
int read_from_ssl;
|
419
420
|
GPR_ASSERT(*unprotected_bytes_size <= INT_MAX);
|
420
421
|
read_from_ssl =
|
@@ -446,7 +447,7 @@ static tsi_result do_ssl_read(SSL *ssl, unsigned char *unprotected_bytes,
|
|
446
447
|
}
|
447
448
|
|
448
449
|
/* Performs an SSL_write and handle errors. */
|
449
|
-
static tsi_result do_ssl_write(SSL
|
450
|
+
static tsi_result do_ssl_write(SSL* ssl, unsigned char* unprotected_bytes,
|
450
451
|
size_t unprotected_bytes_size) {
|
451
452
|
int ssl_write_result;
|
452
453
|
GPR_ASSERT(unprotected_bytes_size <= INT_MAX);
|
@@ -468,19 +469,19 @@ static tsi_result do_ssl_write(SSL *ssl, unsigned char *unprotected_bytes,
|
|
468
469
|
}
|
469
470
|
|
470
471
|
/* Loads an in-memory PEM certificate chain into the SSL context. */
|
471
|
-
static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX
|
472
|
-
const char
|
472
|
+
static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context,
|
473
|
+
const char* pem_cert_chain,
|
473
474
|
size_t pem_cert_chain_size) {
|
474
475
|
tsi_result result = TSI_OK;
|
475
|
-
X509
|
476
|
-
BIO
|
476
|
+
X509* certificate = nullptr;
|
477
|
+
BIO* pem;
|
477
478
|
GPR_ASSERT(pem_cert_chain_size <= INT_MAX);
|
478
|
-
pem = BIO_new_mem_buf((void
|
479
|
-
if (pem ==
|
479
|
+
pem = BIO_new_mem_buf((void*)pem_cert_chain, (int)pem_cert_chain_size);
|
480
|
+
if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
|
480
481
|
|
481
482
|
do {
|
482
|
-
certificate = PEM_read_bio_X509_AUX(pem,
|
483
|
-
if (certificate ==
|
483
|
+
certificate = PEM_read_bio_X509_AUX(pem, nullptr, nullptr, (void*)"");
|
484
|
+
if (certificate == nullptr) {
|
484
485
|
result = TSI_INVALID_ARGUMENT;
|
485
486
|
break;
|
486
487
|
}
|
@@ -489,8 +490,9 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX *context,
|
|
489
490
|
break;
|
490
491
|
}
|
491
492
|
while (1) {
|
492
|
-
X509
|
493
|
-
|
493
|
+
X509* certificate_authority =
|
494
|
+
PEM_read_bio_X509(pem, nullptr, nullptr, (void*)"");
|
495
|
+
if (certificate_authority == nullptr) {
|
494
496
|
ERR_clear_error();
|
495
497
|
break; /* Done reading. */
|
496
498
|
}
|
@@ -505,23 +507,23 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX *context,
|
|
505
507
|
}
|
506
508
|
} while (0);
|
507
509
|
|
508
|
-
if (certificate !=
|
510
|
+
if (certificate != nullptr) X509_free(certificate);
|
509
511
|
BIO_free(pem);
|
510
512
|
return result;
|
511
513
|
}
|
512
514
|
|
513
515
|
/* Loads an in-memory PEM private key into the SSL context. */
|
514
|
-
static tsi_result ssl_ctx_use_private_key(SSL_CTX
|
516
|
+
static tsi_result ssl_ctx_use_private_key(SSL_CTX* context, const char* pem_key,
|
515
517
|
size_t pem_key_size) {
|
516
518
|
tsi_result result = TSI_OK;
|
517
|
-
EVP_PKEY
|
518
|
-
BIO
|
519
|
+
EVP_PKEY* private_key = nullptr;
|
520
|
+
BIO* pem;
|
519
521
|
GPR_ASSERT(pem_key_size <= INT_MAX);
|
520
|
-
pem = BIO_new_mem_buf((void
|
521
|
-
if (pem ==
|
522
|
+
pem = BIO_new_mem_buf((void*)pem_key, (int)pem_key_size);
|
523
|
+
if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
|
522
524
|
do {
|
523
|
-
private_key = PEM_read_bio_PrivateKey(pem,
|
524
|
-
if (private_key ==
|
525
|
+
private_key = PEM_read_bio_PrivateKey(pem, nullptr, nullptr, (void*)"");
|
526
|
+
if (private_key == nullptr) {
|
525
527
|
result = TSI_INVALID_ARGUMENT;
|
526
528
|
break;
|
527
529
|
}
|
@@ -530,54 +532,54 @@ static tsi_result ssl_ctx_use_private_key(SSL_CTX *context, const char *pem_key,
|
|
530
532
|
break;
|
531
533
|
}
|
532
534
|
} while (0);
|
533
|
-
if (private_key !=
|
535
|
+
if (private_key != nullptr) EVP_PKEY_free(private_key);
|
534
536
|
BIO_free(pem);
|
535
537
|
return result;
|
536
538
|
}
|
537
539
|
|
538
540
|
/* Loads in-memory PEM verification certs into the SSL context and optionally
|
539
541
|
returns the verification cert names (root_names can be NULL). */
|
540
|
-
static tsi_result ssl_ctx_load_verification_certs(SSL_CTX
|
541
|
-
const char
|
542
|
+
static tsi_result ssl_ctx_load_verification_certs(SSL_CTX* context,
|
543
|
+
const char* pem_roots,
|
542
544
|
size_t pem_roots_size,
|
543
545
|
STACK_OF(X509_NAME) *
|
544
546
|
*root_names) {
|
545
547
|
tsi_result result = TSI_OK;
|
546
548
|
size_t num_roots = 0;
|
547
|
-
X509
|
548
|
-
X509_NAME
|
549
|
-
BIO
|
550
|
-
X509_STORE
|
549
|
+
X509* root = nullptr;
|
550
|
+
X509_NAME* root_name = nullptr;
|
551
|
+
BIO* pem;
|
552
|
+
X509_STORE* root_store;
|
551
553
|
GPR_ASSERT(pem_roots_size <= INT_MAX);
|
552
|
-
pem = BIO_new_mem_buf((void
|
554
|
+
pem = BIO_new_mem_buf((void*)pem_roots, (int)pem_roots_size);
|
553
555
|
root_store = SSL_CTX_get_cert_store(context);
|
554
|
-
if (root_store ==
|
555
|
-
if (pem ==
|
556
|
-
if (root_names !=
|
556
|
+
if (root_store == nullptr) return TSI_INVALID_ARGUMENT;
|
557
|
+
if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
|
558
|
+
if (root_names != nullptr) {
|
557
559
|
*root_names = sk_X509_NAME_new_null();
|
558
|
-
if (*root_names ==
|
560
|
+
if (*root_names == nullptr) return TSI_OUT_OF_RESOURCES;
|
559
561
|
}
|
560
562
|
|
561
563
|
while (1) {
|
562
|
-
root = PEM_read_bio_X509_AUX(pem,
|
563
|
-
if (root ==
|
564
|
+
root = PEM_read_bio_X509_AUX(pem, nullptr, nullptr, (void*)"");
|
565
|
+
if (root == nullptr) {
|
564
566
|
ERR_clear_error();
|
565
567
|
break; /* We're at the end of stream. */
|
566
568
|
}
|
567
|
-
if (root_names !=
|
569
|
+
if (root_names != nullptr) {
|
568
570
|
root_name = X509_get_subject_name(root);
|
569
|
-
if (root_name ==
|
571
|
+
if (root_name == nullptr) {
|
570
572
|
gpr_log(GPR_ERROR, "Could not get name from root certificate.");
|
571
573
|
result = TSI_INVALID_ARGUMENT;
|
572
574
|
break;
|
573
575
|
}
|
574
576
|
root_name = X509_NAME_dup(root_name);
|
575
|
-
if (root_name ==
|
577
|
+
if (root_name == nullptr) {
|
576
578
|
result = TSI_OUT_OF_RESOURCES;
|
577
579
|
break;
|
578
580
|
}
|
579
581
|
sk_X509_NAME_push(*root_names, root_name);
|
580
|
-
root_name =
|
582
|
+
root_name = nullptr;
|
581
583
|
}
|
582
584
|
if (!X509_STORE_add_cert(root_store, root)) {
|
583
585
|
gpr_log(GPR_ERROR, "Could not add root certificate to ssl context.");
|
@@ -594,11 +596,11 @@ static tsi_result ssl_ctx_load_verification_certs(SSL_CTX *context,
|
|
594
596
|
}
|
595
597
|
|
596
598
|
if (result != TSI_OK) {
|
597
|
-
if (root !=
|
598
|
-
if (root_names !=
|
599
|
+
if (root != nullptr) X509_free(root);
|
600
|
+
if (root_names != nullptr) {
|
599
601
|
sk_X509_NAME_pop_free(*root_names, X509_NAME_free);
|
600
|
-
*root_names =
|
601
|
-
if (root_name !=
|
602
|
+
*root_names = nullptr;
|
603
|
+
if (root_name != nullptr) X509_NAME_free(root_name);
|
602
604
|
}
|
603
605
|
}
|
604
606
|
BIO_free(pem);
|
@@ -608,11 +610,11 @@ static tsi_result ssl_ctx_load_verification_certs(SSL_CTX *context,
|
|
608
610
|
/* Populates the SSL context with a private key and a cert chain, and sets the
|
609
611
|
cipher list and the ephemeral ECDH key. */
|
610
612
|
static tsi_result populate_ssl_context(
|
611
|
-
SSL_CTX
|
612
|
-
const char
|
613
|
+
SSL_CTX* context, const tsi_ssl_pem_key_cert_pair* key_cert_pair,
|
614
|
+
const char* cipher_list) {
|
613
615
|
tsi_result result = TSI_OK;
|
614
|
-
if (key_cert_pair !=
|
615
|
-
if (key_cert_pair->cert_chain !=
|
616
|
+
if (key_cert_pair != nullptr) {
|
617
|
+
if (key_cert_pair->cert_chain != nullptr) {
|
616
618
|
result = ssl_ctx_use_certificate_chain(context, key_cert_pair->cert_chain,
|
617
619
|
strlen(key_cert_pair->cert_chain));
|
618
620
|
if (result != TSI_OK) {
|
@@ -620,7 +622,7 @@ static tsi_result populate_ssl_context(
|
|
620
622
|
return result;
|
621
623
|
}
|
622
624
|
}
|
623
|
-
if (key_cert_pair->private_key !=
|
625
|
+
if (key_cert_pair->private_key != nullptr) {
|
624
626
|
result = ssl_ctx_use_private_key(context, key_cert_pair->private_key,
|
625
627
|
strlen(key_cert_pair->private_key));
|
626
628
|
if (result != TSI_OK || !SSL_CTX_check_private_key(context)) {
|
@@ -629,12 +631,13 @@ static tsi_result populate_ssl_context(
|
|
629
631
|
}
|
630
632
|
}
|
631
633
|
}
|
632
|
-
if ((cipher_list !=
|
634
|
+
if ((cipher_list != nullptr) &&
|
635
|
+
!SSL_CTX_set_cipher_list(context, cipher_list)) {
|
633
636
|
gpr_log(GPR_ERROR, "Invalid cipher list: %s.", cipher_list);
|
634
637
|
return TSI_INVALID_ARGUMENT;
|
635
638
|
}
|
636
639
|
{
|
637
|
-
EC_KEY
|
640
|
+
EC_KEY* ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
|
638
641
|
if (!SSL_CTX_set_tmp_ecdh(context, ecdh)) {
|
639
642
|
gpr_log(GPR_ERROR, "Could not set ephemeral ECDH key.");
|
640
643
|
EC_KEY_free(ecdh);
|
@@ -647,45 +650,46 @@ static tsi_result populate_ssl_context(
|
|
647
650
|
}
|
648
651
|
|
649
652
|
/* Extracts the CN and the SANs from an X509 cert as a peer object. */
|
650
|
-
static tsi_result extract_x509_subject_names_from_pem_cert(const char
|
651
|
-
tsi_peer
|
653
|
+
static tsi_result extract_x509_subject_names_from_pem_cert(const char* pem_cert,
|
654
|
+
tsi_peer* peer) {
|
652
655
|
tsi_result result = TSI_OK;
|
653
|
-
X509
|
654
|
-
BIO
|
655
|
-
pem = BIO_new_mem_buf((void
|
656
|
-
if (pem ==
|
656
|
+
X509* cert = nullptr;
|
657
|
+
BIO* pem;
|
658
|
+
pem = BIO_new_mem_buf((void*)pem_cert, (int)strlen(pem_cert));
|
659
|
+
if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
|
657
660
|
|
658
|
-
cert = PEM_read_bio_X509(pem,
|
659
|
-
if (cert ==
|
661
|
+
cert = PEM_read_bio_X509(pem, nullptr, nullptr, (void*)"");
|
662
|
+
if (cert == nullptr) {
|
660
663
|
gpr_log(GPR_ERROR, "Invalid certificate");
|
661
664
|
result = TSI_INVALID_ARGUMENT;
|
662
665
|
} else {
|
663
666
|
result = peer_from_x509(cert, 0, peer);
|
664
667
|
}
|
665
|
-
if (cert !=
|
668
|
+
if (cert != nullptr) X509_free(cert);
|
666
669
|
BIO_free(pem);
|
667
670
|
return result;
|
668
671
|
}
|
669
672
|
|
670
673
|
/* Builds the alpn protocol name list according to rfc 7301. */
|
671
674
|
static tsi_result build_alpn_protocol_name_list(
|
672
|
-
const char
|
673
|
-
unsigned char
|
675
|
+
const char** alpn_protocols, uint16_t num_alpn_protocols,
|
676
|
+
unsigned char** protocol_name_list, size_t* protocol_name_list_length) {
|
674
677
|
uint16_t i;
|
675
|
-
unsigned char
|
676
|
-
*protocol_name_list =
|
678
|
+
unsigned char* current;
|
679
|
+
*protocol_name_list = nullptr;
|
677
680
|
*protocol_name_list_length = 0;
|
678
681
|
if (num_alpn_protocols == 0) return TSI_INVALID_ARGUMENT;
|
679
682
|
for (i = 0; i < num_alpn_protocols; i++) {
|
680
|
-
size_t length =
|
683
|
+
size_t length =
|
684
|
+
alpn_protocols[i] == nullptr ? 0 : strlen(alpn_protocols[i]);
|
681
685
|
if (length == 0 || length > 255) {
|
682
686
|
gpr_log(GPR_ERROR, "Invalid protocol name length: %d.", (int)length);
|
683
687
|
return TSI_INVALID_ARGUMENT;
|
684
688
|
}
|
685
689
|
*protocol_name_list_length += length + 1;
|
686
690
|
}
|
687
|
-
*protocol_name_list = gpr_malloc(*protocol_name_list_length);
|
688
|
-
if (*protocol_name_list ==
|
691
|
+
*protocol_name_list = (unsigned char*)gpr_malloc(*protocol_name_list_length);
|
692
|
+
if (*protocol_name_list == nullptr) return TSI_OUT_OF_RESOURCES;
|
689
693
|
current = *protocol_name_list;
|
690
694
|
for (i = 0; i < num_alpn_protocols; i++) {
|
691
695
|
size_t length = strlen(alpn_protocols[i]);
|
@@ -706,18 +710,18 @@ static tsi_result build_alpn_protocol_name_list(
|
|
706
710
|
// the server's certificate, but we need to pull it anyway, in case a higher
|
707
711
|
// layer wants to look at it. In this case the verification may fail, but
|
708
712
|
// we don't really care.
|
709
|
-
static int NullVerifyCallback(int preverify_ok, X509_STORE_CTX
|
713
|
+
static int NullVerifyCallback(int preverify_ok, X509_STORE_CTX* ctx) {
|
710
714
|
return 1;
|
711
715
|
}
|
712
716
|
|
713
717
|
/* --- tsi_frame_protector methods implementation. ---*/
|
714
718
|
|
715
|
-
static tsi_result ssl_protector_protect(tsi_frame_protector
|
716
|
-
const unsigned char
|
717
|
-
size_t
|
718
|
-
unsigned char
|
719
|
-
size_t
|
720
|
-
tsi_ssl_frame_protector
|
719
|
+
static tsi_result ssl_protector_protect(tsi_frame_protector* self,
|
720
|
+
const unsigned char* unprotected_bytes,
|
721
|
+
size_t* unprotected_bytes_size,
|
722
|
+
unsigned char* protected_output_frames,
|
723
|
+
size_t* protected_output_frames_size) {
|
724
|
+
tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
|
721
725
|
int read_from_ssl;
|
722
726
|
size_t available;
|
723
727
|
tsi_result result = TSI_OK;
|
@@ -768,10 +772,10 @@ static tsi_result ssl_protector_protect(tsi_frame_protector *self,
|
|
768
772
|
}
|
769
773
|
|
770
774
|
static tsi_result ssl_protector_protect_flush(
|
771
|
-
tsi_frame_protector
|
772
|
-
size_t
|
775
|
+
tsi_frame_protector* self, unsigned char* protected_output_frames,
|
776
|
+
size_t* protected_output_frames_size, size_t* still_pending_size) {
|
773
777
|
tsi_result result = TSI_OK;
|
774
|
-
tsi_ssl_frame_protector
|
778
|
+
tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
|
775
779
|
int read_from_ssl = 0;
|
776
780
|
int pending;
|
777
781
|
|
@@ -801,14 +805,14 @@ static tsi_result ssl_protector_protect_flush(
|
|
801
805
|
}
|
802
806
|
|
803
807
|
static tsi_result ssl_protector_unprotect(
|
804
|
-
tsi_frame_protector
|
805
|
-
size_t
|
806
|
-
size_t
|
808
|
+
tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
|
809
|
+
size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
|
810
|
+
size_t* unprotected_bytes_size) {
|
807
811
|
tsi_result result = TSI_OK;
|
808
812
|
int written_into_ssl = 0;
|
809
813
|
size_t output_bytes_size = *unprotected_bytes_size;
|
810
814
|
size_t output_bytes_offset = 0;
|
811
|
-
tsi_ssl_frame_protector
|
815
|
+
tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
|
812
816
|
|
813
817
|
/* First, try to read remaining data from ssl. */
|
814
818
|
result = do_ssl_read(impl->ssl, unprotected_bytes, unprotected_bytes_size);
|
@@ -842,25 +846,27 @@ static tsi_result ssl_protector_unprotect(
|
|
842
846
|
return result;
|
843
847
|
}
|
844
848
|
|
845
|
-
static void ssl_protector_destroy(tsi_frame_protector
|
846
|
-
tsi_ssl_frame_protector
|
847
|
-
if (impl->buffer !=
|
848
|
-
if (impl->ssl !=
|
849
|
+
static void ssl_protector_destroy(tsi_frame_protector* self) {
|
850
|
+
tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
|
851
|
+
if (impl->buffer != nullptr) gpr_free(impl->buffer);
|
852
|
+
if (impl->ssl != nullptr) SSL_free(impl->ssl);
|
849
853
|
gpr_free(self);
|
850
854
|
}
|
851
855
|
|
852
856
|
static const tsi_frame_protector_vtable frame_protector_vtable = {
|
853
|
-
ssl_protector_protect,
|
857
|
+
ssl_protector_protect,
|
858
|
+
ssl_protector_protect_flush,
|
859
|
+
ssl_protector_unprotect,
|
854
860
|
ssl_protector_destroy,
|
855
861
|
};
|
856
862
|
|
857
863
|
/* --- tsi_server_handshaker_factory methods implementation. --- */
|
858
864
|
|
859
865
|
static void tsi_ssl_handshaker_factory_destroy(
|
860
|
-
tsi_ssl_handshaker_factory
|
861
|
-
if (self ==
|
866
|
+
tsi_ssl_handshaker_factory* self) {
|
867
|
+
if (self == nullptr) return;
|
862
868
|
|
863
|
-
if (self->vtable !=
|
869
|
+
if (self->vtable != nullptr && self->vtable->destroy != nullptr) {
|
864
870
|
self->vtable->destroy(self);
|
865
871
|
}
|
866
872
|
/* Note, we don't free(self) here because this object is always directly
|
@@ -868,28 +874,28 @@ static void tsi_ssl_handshaker_factory_destroy(
|
|
868
874
|
* any memory, it should be free'd here. */
|
869
875
|
}
|
870
876
|
|
871
|
-
static tsi_ssl_handshaker_factory
|
872
|
-
tsi_ssl_handshaker_factory
|
873
|
-
if (self ==
|
877
|
+
static tsi_ssl_handshaker_factory* tsi_ssl_handshaker_factory_ref(
|
878
|
+
tsi_ssl_handshaker_factory* self) {
|
879
|
+
if (self == nullptr) return nullptr;
|
874
880
|
gpr_refn(&self->refcount, 1);
|
875
881
|
return self;
|
876
882
|
}
|
877
883
|
|
878
|
-
static void tsi_ssl_handshaker_factory_unref(tsi_ssl_handshaker_factory
|
879
|
-
if (self ==
|
884
|
+
static void tsi_ssl_handshaker_factory_unref(tsi_ssl_handshaker_factory* self) {
|
885
|
+
if (self == nullptr) return;
|
880
886
|
|
881
887
|
if (gpr_unref(&self->refcount)) {
|
882
888
|
tsi_ssl_handshaker_factory_destroy(self);
|
883
889
|
}
|
884
890
|
}
|
885
891
|
|
886
|
-
static tsi_ssl_handshaker_factory_vtable handshaker_factory_vtable = {
|
892
|
+
static tsi_ssl_handshaker_factory_vtable handshaker_factory_vtable = {nullptr};
|
887
893
|
|
888
894
|
/* Initializes a tsi_ssl_handshaker_factory object. Caller is responsible for
|
889
895
|
* allocating memory for the factory. */
|
890
896
|
static void tsi_ssl_handshaker_factory_init(
|
891
|
-
tsi_ssl_handshaker_factory
|
892
|
-
GPR_ASSERT(factory !=
|
897
|
+
tsi_ssl_handshaker_factory* factory) {
|
898
|
+
GPR_ASSERT(factory != nullptr);
|
893
899
|
|
894
900
|
factory->vtable = &handshaker_factory_vtable;
|
895
901
|
gpr_ref_init(&factory->refcount, 1);
|
@@ -897,12 +903,12 @@ static void tsi_ssl_handshaker_factory_init(
|
|
897
903
|
|
898
904
|
/* --- tsi_handshaker methods implementation. ---*/
|
899
905
|
|
900
|
-
static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker
|
901
|
-
unsigned char
|
902
|
-
size_t
|
903
|
-
tsi_ssl_handshaker
|
906
|
+
static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
|
907
|
+
unsigned char* bytes,
|
908
|
+
size_t* bytes_size) {
|
909
|
+
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
|
904
910
|
int bytes_read_from_ssl = 0;
|
905
|
-
if (bytes ==
|
911
|
+
if (bytes == nullptr || bytes_size == nullptr || *bytes_size == 0 ||
|
906
912
|
*bytes_size > INT_MAX) {
|
907
913
|
return TSI_INVALID_ARGUMENT;
|
908
914
|
}
|
@@ -921,8 +927,8 @@ static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker *self,
|
|
921
927
|
return BIO_pending(impl->from_ssl) == 0 ? TSI_OK : TSI_INCOMPLETE_DATA;
|
922
928
|
}
|
923
929
|
|
924
|
-
static tsi_result ssl_handshaker_get_result(tsi_handshaker
|
925
|
-
tsi_ssl_handshaker
|
930
|
+
static tsi_result ssl_handshaker_get_result(tsi_handshaker* self) {
|
931
|
+
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
|
926
932
|
if ((impl->result == TSI_HANDSHAKE_IN_PROGRESS) &&
|
927
933
|
SSL_is_init_finished(impl->ssl)) {
|
928
934
|
impl->result = TSI_OK;
|
@@ -931,10 +937,10 @@ static tsi_result ssl_handshaker_get_result(tsi_handshaker *self) {
|
|
931
937
|
}
|
932
938
|
|
933
939
|
static tsi_result ssl_handshaker_process_bytes_from_peer(
|
934
|
-
tsi_handshaker
|
935
|
-
tsi_ssl_handshaker
|
940
|
+
tsi_handshaker* self, const unsigned char* bytes, size_t* bytes_size) {
|
941
|
+
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
|
936
942
|
int bytes_written_into_ssl_size = 0;
|
937
|
-
if (bytes ==
|
943
|
+
if (bytes == nullptr || bytes_size == nullptr || *bytes_size > INT_MAX) {
|
938
944
|
return TSI_INVALID_ARGUMENT;
|
939
945
|
}
|
940
946
|
GPR_ASSERT(*bytes_size <= INT_MAX);
|
@@ -976,14 +982,14 @@ static tsi_result ssl_handshaker_process_bytes_from_peer(
|
|
976
982
|
}
|
977
983
|
}
|
978
984
|
|
979
|
-
static tsi_result ssl_handshaker_extract_peer(tsi_handshaker
|
980
|
-
tsi_peer
|
985
|
+
static tsi_result ssl_handshaker_extract_peer(tsi_handshaker* self,
|
986
|
+
tsi_peer* peer) {
|
981
987
|
tsi_result result = TSI_OK;
|
982
|
-
const unsigned char
|
988
|
+
const unsigned char* alpn_selected = nullptr;
|
983
989
|
unsigned int alpn_selected_len;
|
984
|
-
tsi_ssl_handshaker
|
985
|
-
X509
|
986
|
-
if (peer_cert !=
|
990
|
+
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
|
991
|
+
X509* peer_cert = SSL_get_peer_certificate(impl->ssl);
|
992
|
+
if (peer_cert != nullptr) {
|
987
993
|
result = peer_from_x509(peer_cert, 1, peer);
|
988
994
|
X509_free(peer_cert);
|
989
995
|
if (result != TSI_OK) return result;
|
@@ -991,26 +997,26 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker *self,
|
|
991
997
|
#if TSI_OPENSSL_ALPN_SUPPORT
|
992
998
|
SSL_get0_alpn_selected(impl->ssl, &alpn_selected, &alpn_selected_len);
|
993
999
|
#endif /* TSI_OPENSSL_ALPN_SUPPORT */
|
994
|
-
if (alpn_selected ==
|
1000
|
+
if (alpn_selected == nullptr) {
|
995
1001
|
/* Try npn. */
|
996
1002
|
SSL_get0_next_proto_negotiated(impl->ssl, &alpn_selected,
|
997
1003
|
&alpn_selected_len);
|
998
1004
|
}
|
999
|
-
if (alpn_selected !=
|
1005
|
+
if (alpn_selected != nullptr) {
|
1000
1006
|
size_t i;
|
1001
|
-
tsi_peer_property
|
1002
|
-
|
1007
|
+
tsi_peer_property* new_properties = (tsi_peer_property*)gpr_zalloc(
|
1008
|
+
sizeof(*new_properties) * (peer->property_count + 1));
|
1003
1009
|
for (i = 0; i < peer->property_count; i++) {
|
1004
1010
|
new_properties[i] = peer->properties[i];
|
1005
1011
|
}
|
1006
1012
|
result = tsi_construct_string_peer_property(
|
1007
|
-
TSI_SSL_ALPN_SELECTED_PROTOCOL, (const char
|
1013
|
+
TSI_SSL_ALPN_SELECTED_PROTOCOL, (const char*)alpn_selected,
|
1008
1014
|
alpn_selected_len, &new_properties[peer->property_count]);
|
1009
1015
|
if (result != TSI_OK) {
|
1010
1016
|
gpr_free(new_properties);
|
1011
1017
|
return result;
|
1012
1018
|
}
|
1013
|
-
if (peer->properties !=
|
1019
|
+
if (peer->properties != nullptr) gpr_free(peer->properties);
|
1014
1020
|
peer->property_count++;
|
1015
1021
|
peer->properties = new_properties;
|
1016
1022
|
}
|
@@ -1018,14 +1024,15 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker *self,
|
|
1018
1024
|
}
|
1019
1025
|
|
1020
1026
|
static tsi_result ssl_handshaker_create_frame_protector(
|
1021
|
-
tsi_handshaker
|
1022
|
-
tsi_frame_protector
|
1027
|
+
tsi_handshaker* self, size_t* max_output_protected_frame_size,
|
1028
|
+
tsi_frame_protector** protector) {
|
1023
1029
|
size_t actual_max_output_protected_frame_size =
|
1024
1030
|
TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND;
|
1025
|
-
tsi_ssl_handshaker
|
1026
|
-
tsi_ssl_frame_protector
|
1031
|
+
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
|
1032
|
+
tsi_ssl_frame_protector* protector_impl =
|
1033
|
+
(tsi_ssl_frame_protector*)gpr_zalloc(sizeof(*protector_impl));
|
1027
1034
|
|
1028
|
-
if (max_output_protected_frame_size !=
|
1035
|
+
if (max_output_protected_frame_size != nullptr) {
|
1029
1036
|
if (*max_output_protected_frame_size >
|
1030
1037
|
TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND) {
|
1031
1038
|
*max_output_protected_frame_size =
|
@@ -1039,8 +1046,9 @@ static tsi_result ssl_handshaker_create_frame_protector(
|
|
1039
1046
|
}
|
1040
1047
|
protector_impl->buffer_size =
|
1041
1048
|
actual_max_output_protected_frame_size - TSI_SSL_MAX_PROTECTION_OVERHEAD;
|
1042
|
-
protector_impl->buffer =
|
1043
|
-
|
1049
|
+
protector_impl->buffer =
|
1050
|
+
(unsigned char*)gpr_malloc(protector_impl->buffer_size);
|
1051
|
+
if (protector_impl->buffer == nullptr) {
|
1044
1052
|
gpr_log(GPR_ERROR,
|
1045
1053
|
"Could not allocated buffer for tsi_ssl_frame_protector.");
|
1046
1054
|
gpr_free(protector_impl);
|
@@ -1050,7 +1058,7 @@ static tsi_result ssl_handshaker_create_frame_protector(
|
|
1050
1058
|
/* Transfer ownership of ssl to the frame protector. It is OK as the caller
|
1051
1059
|
* cannot call anything else but destroy on the handshaker after this call. */
|
1052
1060
|
protector_impl->ssl = impl->ssl;
|
1053
|
-
impl->ssl =
|
1061
|
+
impl->ssl = nullptr;
|
1054
1062
|
protector_impl->into_ssl = impl->into_ssl;
|
1055
1063
|
protector_impl->from_ssl = impl->from_ssl;
|
1056
1064
|
|
@@ -1059,8 +1067,8 @@ static tsi_result ssl_handshaker_create_frame_protector(
|
|
1059
1067
|
return TSI_OK;
|
1060
1068
|
}
|
1061
1069
|
|
1062
|
-
static void ssl_handshaker_destroy(tsi_handshaker
|
1063
|
-
tsi_ssl_handshaker
|
1070
|
+
static void ssl_handshaker_destroy(tsi_handshaker* self) {
|
1071
|
+
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
|
1064
1072
|
SSL_free(impl->ssl); /* The BIO objects are owned by ssl */
|
1065
1073
|
tsi_ssl_handshaker_factory_unref(impl->factory_ref);
|
1066
1074
|
gpr_free(impl);
|
@@ -1073,43 +1081,43 @@ static const tsi_handshaker_vtable handshaker_vtable = {
|
|
1073
1081
|
ssl_handshaker_extract_peer,
|
1074
1082
|
ssl_handshaker_create_frame_protector,
|
1075
1083
|
ssl_handshaker_destroy,
|
1076
|
-
|
1084
|
+
nullptr,
|
1077
1085
|
};
|
1078
1086
|
|
1079
1087
|
/* --- tsi_ssl_handshaker_factory common methods. --- */
|
1080
1088
|
|
1081
|
-
static tsi_result create_tsi_ssl_handshaker(SSL_CTX
|
1082
|
-
const char
|
1083
|
-
tsi_ssl_handshaker_factory
|
1084
|
-
tsi_handshaker
|
1085
|
-
SSL
|
1086
|
-
BIO
|
1087
|
-
BIO
|
1088
|
-
tsi_ssl_handshaker
|
1089
|
-
*handshaker =
|
1090
|
-
if (ctx ==
|
1089
|
+
static tsi_result create_tsi_ssl_handshaker(SSL_CTX* ctx, int is_client,
|
1090
|
+
const char* server_name_indication,
|
1091
|
+
tsi_ssl_handshaker_factory* factory,
|
1092
|
+
tsi_handshaker** handshaker) {
|
1093
|
+
SSL* ssl = SSL_new(ctx);
|
1094
|
+
BIO* into_ssl = nullptr;
|
1095
|
+
BIO* from_ssl = nullptr;
|
1096
|
+
tsi_ssl_handshaker* impl = nullptr;
|
1097
|
+
*handshaker = nullptr;
|
1098
|
+
if (ctx == nullptr) {
|
1091
1099
|
gpr_log(GPR_ERROR, "SSL Context is null. Should never happen.");
|
1092
1100
|
return TSI_INTERNAL_ERROR;
|
1093
1101
|
}
|
1094
|
-
if (ssl ==
|
1102
|
+
if (ssl == nullptr) {
|
1095
1103
|
return TSI_OUT_OF_RESOURCES;
|
1096
1104
|
}
|
1097
1105
|
SSL_set_info_callback(ssl, ssl_info_callback);
|
1098
1106
|
|
1099
1107
|
into_ssl = BIO_new(BIO_s_mem());
|
1100
1108
|
from_ssl = BIO_new(BIO_s_mem());
|
1101
|
-
if (into_ssl ==
|
1109
|
+
if (into_ssl == nullptr || from_ssl == nullptr) {
|
1102
1110
|
gpr_log(GPR_ERROR, "BIO_new failed.");
|
1103
1111
|
SSL_free(ssl);
|
1104
|
-
if (into_ssl !=
|
1105
|
-
if (from_ssl !=
|
1112
|
+
if (into_ssl != nullptr) BIO_free(into_ssl);
|
1113
|
+
if (from_ssl != nullptr) BIO_free(into_ssl);
|
1106
1114
|
return TSI_OUT_OF_RESOURCES;
|
1107
1115
|
}
|
1108
1116
|
SSL_set_bio(ssl, into_ssl, from_ssl);
|
1109
1117
|
if (is_client) {
|
1110
1118
|
int ssl_result;
|
1111
1119
|
SSL_set_connect_state(ssl);
|
1112
|
-
if (server_name_indication !=
|
1120
|
+
if (server_name_indication != nullptr) {
|
1113
1121
|
if (!SSL_set_tlsext_host_name(ssl, server_name_indication)) {
|
1114
1122
|
gpr_log(GPR_ERROR, "Invalid server name indication %s.",
|
1115
1123
|
server_name_indication);
|
@@ -1130,7 +1138,7 @@ static tsi_result create_tsi_ssl_handshaker(SSL_CTX *ctx, int is_client,
|
|
1130
1138
|
SSL_set_accept_state(ssl);
|
1131
1139
|
}
|
1132
1140
|
|
1133
|
-
impl = gpr_zalloc(sizeof(*impl));
|
1141
|
+
impl = (tsi_ssl_handshaker*)gpr_zalloc(sizeof(*impl));
|
1134
1142
|
impl->ssl = ssl;
|
1135
1143
|
impl->into_ssl = into_ssl;
|
1136
1144
|
impl->from_ssl = from_ssl;
|
@@ -1142,16 +1150,16 @@ static tsi_result create_tsi_ssl_handshaker(SSL_CTX *ctx, int is_client,
|
|
1142
1150
|
return TSI_OK;
|
1143
1151
|
}
|
1144
1152
|
|
1145
|
-
static int select_protocol_list(const unsigned char
|
1146
|
-
unsigned char
|
1147
|
-
const unsigned char
|
1153
|
+
static int select_protocol_list(const unsigned char** out,
|
1154
|
+
unsigned char* outlen,
|
1155
|
+
const unsigned char* client_list,
|
1148
1156
|
size_t client_list_len,
|
1149
|
-
const unsigned char
|
1157
|
+
const unsigned char* server_list,
|
1150
1158
|
size_t server_list_len) {
|
1151
|
-
const unsigned char
|
1159
|
+
const unsigned char* client_current = client_list;
|
1152
1160
|
while ((unsigned int)(client_current - client_list) < client_list_len) {
|
1153
1161
|
unsigned char client_current_len = *(client_current++);
|
1154
|
-
const unsigned char
|
1162
|
+
const unsigned char* server_current = server_list;
|
1155
1163
|
while ((server_current >= server_list) &&
|
1156
1164
|
(uintptr_t)(server_current - server_list) < server_list_len) {
|
1157
1165
|
unsigned char server_current_len = *(server_current++);
|
@@ -1171,36 +1179,36 @@ static int select_protocol_list(const unsigned char **out,
|
|
1171
1179
|
/* --- tsi_ssl_client_handshaker_factory methods implementation. --- */
|
1172
1180
|
|
1173
1181
|
tsi_result tsi_ssl_client_handshaker_factory_create_handshaker(
|
1174
|
-
tsi_ssl_client_handshaker_factory
|
1175
|
-
tsi_handshaker
|
1182
|
+
tsi_ssl_client_handshaker_factory* self, const char* server_name_indication,
|
1183
|
+
tsi_handshaker** handshaker) {
|
1176
1184
|
return create_tsi_ssl_handshaker(self->ssl_context, 1, server_name_indication,
|
1177
1185
|
&self->base, handshaker);
|
1178
1186
|
}
|
1179
1187
|
|
1180
1188
|
void tsi_ssl_client_handshaker_factory_unref(
|
1181
|
-
tsi_ssl_client_handshaker_factory
|
1182
|
-
if (self ==
|
1189
|
+
tsi_ssl_client_handshaker_factory* self) {
|
1190
|
+
if (self == nullptr) return;
|
1183
1191
|
tsi_ssl_handshaker_factory_unref(&self->base);
|
1184
1192
|
}
|
1185
1193
|
|
1186
1194
|
static void tsi_ssl_client_handshaker_factory_destroy(
|
1187
|
-
tsi_ssl_handshaker_factory
|
1188
|
-
if (factory ==
|
1189
|
-
tsi_ssl_client_handshaker_factory
|
1190
|
-
(tsi_ssl_client_handshaker_factory
|
1191
|
-
if (self->ssl_context !=
|
1192
|
-
if (self->alpn_protocol_list !=
|
1195
|
+
tsi_ssl_handshaker_factory* factory) {
|
1196
|
+
if (factory == nullptr) return;
|
1197
|
+
tsi_ssl_client_handshaker_factory* self =
|
1198
|
+
(tsi_ssl_client_handshaker_factory*)factory;
|
1199
|
+
if (self->ssl_context != nullptr) SSL_CTX_free(self->ssl_context);
|
1200
|
+
if (self->alpn_protocol_list != nullptr) gpr_free(self->alpn_protocol_list);
|
1193
1201
|
gpr_free(self);
|
1194
1202
|
}
|
1195
1203
|
|
1196
|
-
static int client_handshaker_factory_npn_callback(SSL
|
1197
|
-
unsigned char
|
1198
|
-
const unsigned char
|
1204
|
+
static int client_handshaker_factory_npn_callback(SSL* ssl, unsigned char** out,
|
1205
|
+
unsigned char* outlen,
|
1206
|
+
const unsigned char* in,
|
1199
1207
|
unsigned int inlen,
|
1200
|
-
void
|
1201
|
-
tsi_ssl_client_handshaker_factory
|
1202
|
-
(tsi_ssl_client_handshaker_factory
|
1203
|
-
return select_protocol_list((const unsigned char
|
1208
|
+
void* arg) {
|
1209
|
+
tsi_ssl_client_handshaker_factory* factory =
|
1210
|
+
(tsi_ssl_client_handshaker_factory*)arg;
|
1211
|
+
return select_protocol_list((const unsigned char**)out, outlen,
|
1204
1212
|
factory->alpn_protocol_list,
|
1205
1213
|
factory->alpn_protocol_list_length, in, inlen);
|
1206
1214
|
}
|
@@ -1208,44 +1216,44 @@ static int client_handshaker_factory_npn_callback(SSL *ssl, unsigned char **out,
|
|
1208
1216
|
/* --- tsi_ssl_server_handshaker_factory methods implementation. --- */
|
1209
1217
|
|
1210
1218
|
tsi_result tsi_ssl_server_handshaker_factory_create_handshaker(
|
1211
|
-
tsi_ssl_server_handshaker_factory
|
1219
|
+
tsi_ssl_server_handshaker_factory* self, tsi_handshaker** handshaker) {
|
1212
1220
|
if (self->ssl_context_count == 0) return TSI_INVALID_ARGUMENT;
|
1213
1221
|
/* Create the handshaker with the first context. We will switch if needed
|
1214
1222
|
because of SNI in ssl_server_handshaker_factory_servername_callback. */
|
1215
|
-
return create_tsi_ssl_handshaker(self->ssl_contexts[0], 0,
|
1216
|
-
handshaker);
|
1223
|
+
return create_tsi_ssl_handshaker(self->ssl_contexts[0], 0, nullptr,
|
1224
|
+
&self->base, handshaker);
|
1217
1225
|
}
|
1218
1226
|
|
1219
1227
|
void tsi_ssl_server_handshaker_factory_unref(
|
1220
|
-
tsi_ssl_server_handshaker_factory
|
1221
|
-
if (self ==
|
1228
|
+
tsi_ssl_server_handshaker_factory* self) {
|
1229
|
+
if (self == nullptr) return;
|
1222
1230
|
tsi_ssl_handshaker_factory_unref(&self->base);
|
1223
1231
|
}
|
1224
1232
|
|
1225
1233
|
static void tsi_ssl_server_handshaker_factory_destroy(
|
1226
|
-
tsi_ssl_handshaker_factory
|
1227
|
-
if (factory ==
|
1228
|
-
tsi_ssl_server_handshaker_factory
|
1229
|
-
(tsi_ssl_server_handshaker_factory
|
1234
|
+
tsi_ssl_handshaker_factory* factory) {
|
1235
|
+
if (factory == nullptr) return;
|
1236
|
+
tsi_ssl_server_handshaker_factory* self =
|
1237
|
+
(tsi_ssl_server_handshaker_factory*)factory;
|
1230
1238
|
size_t i;
|
1231
1239
|
for (i = 0; i < self->ssl_context_count; i++) {
|
1232
|
-
if (self->ssl_contexts[i] !=
|
1240
|
+
if (self->ssl_contexts[i] != nullptr) {
|
1233
1241
|
SSL_CTX_free(self->ssl_contexts[i]);
|
1234
1242
|
tsi_peer_destruct(&self->ssl_context_x509_subject_names[i]);
|
1235
1243
|
}
|
1236
1244
|
}
|
1237
|
-
if (self->ssl_contexts !=
|
1238
|
-
if (self->ssl_context_x509_subject_names !=
|
1245
|
+
if (self->ssl_contexts != nullptr) gpr_free(self->ssl_contexts);
|
1246
|
+
if (self->ssl_context_x509_subject_names != nullptr) {
|
1239
1247
|
gpr_free(self->ssl_context_x509_subject_names);
|
1240
1248
|
}
|
1241
|
-
if (self->alpn_protocol_list !=
|
1249
|
+
if (self->alpn_protocol_list != nullptr) gpr_free(self->alpn_protocol_list);
|
1242
1250
|
gpr_free(self);
|
1243
1251
|
}
|
1244
1252
|
|
1245
|
-
static int does_entry_match_name(const char
|
1246
|
-
const char
|
1247
|
-
const char
|
1248
|
-
const char
|
1253
|
+
static int does_entry_match_name(const char* entry, size_t entry_length,
|
1254
|
+
const char* name) {
|
1255
|
+
const char* dot;
|
1256
|
+
const char* name_subdomain = nullptr;
|
1249
1257
|
size_t name_length = strlen(name);
|
1250
1258
|
size_t name_subdomain_length;
|
1251
1259
|
if (entry_length == 0) return 0;
|
@@ -1271,7 +1279,7 @@ static int does_entry_match_name(const char *entry, size_t entry_length,
|
|
1271
1279
|
return 0;
|
1272
1280
|
}
|
1273
1281
|
name_subdomain = strchr(name, '.');
|
1274
|
-
if (name_subdomain ==
|
1282
|
+
if (name_subdomain == nullptr) return 0;
|
1275
1283
|
name_subdomain_length = strlen(name_subdomain);
|
1276
1284
|
if (name_subdomain_length < 2) return 0;
|
1277
1285
|
name_subdomain++; /* Starts after the dot. */
|
@@ -1279,7 +1287,7 @@ static int does_entry_match_name(const char *entry, size_t entry_length,
|
|
1279
1287
|
entry += 2; /* Remove *. */
|
1280
1288
|
entry_length -= 2;
|
1281
1289
|
dot = strchr(name_subdomain, '.');
|
1282
|
-
if ((dot ==
|
1290
|
+
if ((dot == nullptr) || (dot == &name_subdomain[name_subdomain_length - 1])) {
|
1283
1291
|
gpr_log(GPR_ERROR, "Invalid toplevel subdomain: %s", name_subdomain);
|
1284
1292
|
return 0;
|
1285
1293
|
}
|
@@ -1290,13 +1298,13 @@ static int does_entry_match_name(const char *entry, size_t entry_length,
|
|
1290
1298
|
strncmp(entry, name_subdomain, entry_length) == 0);
|
1291
1299
|
}
|
1292
1300
|
|
1293
|
-
static int ssl_server_handshaker_factory_servername_callback(SSL
|
1294
|
-
void
|
1295
|
-
tsi_ssl_server_handshaker_factory
|
1296
|
-
(tsi_ssl_server_handshaker_factory
|
1301
|
+
static int ssl_server_handshaker_factory_servername_callback(SSL* ssl, int* ap,
|
1302
|
+
void* arg) {
|
1303
|
+
tsi_ssl_server_handshaker_factory* impl =
|
1304
|
+
(tsi_ssl_server_handshaker_factory*)arg;
|
1297
1305
|
size_t i = 0;
|
1298
|
-
const char
|
1299
|
-
if (servername ==
|
1306
|
+
const char* servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
|
1307
|
+
if (servername == nullptr || strlen(servername) == 0) {
|
1300
1308
|
return SSL_TLSEXT_ERR_NOACK;
|
1301
1309
|
}
|
1302
1310
|
|
@@ -1313,10 +1321,10 @@ static int ssl_server_handshaker_factory_servername_callback(SSL *ssl, int *ap,
|
|
1313
1321
|
|
1314
1322
|
#if TSI_OPENSSL_ALPN_SUPPORT
|
1315
1323
|
static int server_handshaker_factory_alpn_callback(
|
1316
|
-
SSL
|
1317
|
-
const unsigned char
|
1318
|
-
tsi_ssl_server_handshaker_factory
|
1319
|
-
(tsi_ssl_server_handshaker_factory
|
1324
|
+
SSL* ssl, const unsigned char** out, unsigned char* outlen,
|
1325
|
+
const unsigned char* in, unsigned int inlen, void* arg) {
|
1326
|
+
tsi_ssl_server_handshaker_factory* factory =
|
1327
|
+
(tsi_ssl_server_handshaker_factory*)arg;
|
1320
1328
|
return select_protocol_list(out, outlen, in, inlen,
|
1321
1329
|
factory->alpn_protocol_list,
|
1322
1330
|
factory->alpn_protocol_list_length);
|
@@ -1324,9 +1332,9 @@ static int server_handshaker_factory_alpn_callback(
|
|
1324
1332
|
#endif /* TSI_OPENSSL_ALPN_SUPPORT */
|
1325
1333
|
|
1326
1334
|
static int server_handshaker_factory_npn_advertised_callback(
|
1327
|
-
SSL
|
1328
|
-
tsi_ssl_server_handshaker_factory
|
1329
|
-
(tsi_ssl_server_handshaker_factory
|
1335
|
+
SSL* ssl, const unsigned char** out, unsigned int* outlen, void* arg) {
|
1336
|
+
tsi_ssl_server_handshaker_factory* factory =
|
1337
|
+
(tsi_ssl_server_handshaker_factory*)arg;
|
1330
1338
|
*out = factory->alpn_protocol_list;
|
1331
1339
|
GPR_ASSERT(factory->alpn_protocol_list_length <= UINT_MAX);
|
1332
1340
|
*outlen = (unsigned int)factory->alpn_protocol_list_length;
|
@@ -1339,27 +1347,27 @@ static tsi_ssl_handshaker_factory_vtable client_handshaker_factory_vtable = {
|
|
1339
1347
|
tsi_ssl_client_handshaker_factory_destroy};
|
1340
1348
|
|
1341
1349
|
tsi_result tsi_create_ssl_client_handshaker_factory(
|
1342
|
-
const tsi_ssl_pem_key_cert_pair
|
1343
|
-
const char
|
1344
|
-
const char
|
1345
|
-
tsi_ssl_client_handshaker_factory
|
1346
|
-
SSL_CTX
|
1347
|
-
tsi_ssl_client_handshaker_factory
|
1350
|
+
const tsi_ssl_pem_key_cert_pair* pem_key_cert_pair,
|
1351
|
+
const char* pem_root_certs, const char* cipher_suites,
|
1352
|
+
const char** alpn_protocols, uint16_t num_alpn_protocols,
|
1353
|
+
tsi_ssl_client_handshaker_factory** factory) {
|
1354
|
+
SSL_CTX* ssl_context = nullptr;
|
1355
|
+
tsi_ssl_client_handshaker_factory* impl = nullptr;
|
1348
1356
|
tsi_result result = TSI_OK;
|
1349
1357
|
|
1350
1358
|
gpr_once_init(&init_openssl_once, init_openssl);
|
1351
1359
|
|
1352
|
-
if (factory ==
|
1353
|
-
*factory =
|
1354
|
-
if (pem_root_certs ==
|
1360
|
+
if (factory == nullptr) return TSI_INVALID_ARGUMENT;
|
1361
|
+
*factory = nullptr;
|
1362
|
+
if (pem_root_certs == nullptr) return TSI_INVALID_ARGUMENT;
|
1355
1363
|
|
1356
1364
|
ssl_context = SSL_CTX_new(TLSv1_2_method());
|
1357
|
-
if (ssl_context ==
|
1365
|
+
if (ssl_context == nullptr) {
|
1358
1366
|
gpr_log(GPR_ERROR, "Could not create ssl context.");
|
1359
1367
|
return TSI_INVALID_ARGUMENT;
|
1360
1368
|
}
|
1361
1369
|
|
1362
|
-
impl = gpr_zalloc(sizeof(*impl));
|
1370
|
+
impl = (tsi_ssl_client_handshaker_factory*)gpr_zalloc(sizeof(*impl));
|
1363
1371
|
tsi_ssl_handshaker_factory_init(&impl->base);
|
1364
1372
|
impl->base.vtable = &client_handshaker_factory_vtable;
|
1365
1373
|
|
@@ -1370,7 +1378,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
|
|
1370
1378
|
populate_ssl_context(ssl_context, pem_key_cert_pair, cipher_suites);
|
1371
1379
|
if (result != TSI_OK) break;
|
1372
1380
|
result = ssl_ctx_load_verification_certs(ssl_context, pem_root_certs,
|
1373
|
-
strlen(pem_root_certs),
|
1381
|
+
strlen(pem_root_certs), nullptr);
|
1374
1382
|
if (result != TSI_OK) {
|
1375
1383
|
gpr_log(GPR_ERROR, "Cannot load server root certificates.");
|
1376
1384
|
break;
|
@@ -1403,7 +1411,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
|
|
1403
1411
|
tsi_ssl_handshaker_factory_unref(&impl->base);
|
1404
1412
|
return result;
|
1405
1413
|
}
|
1406
|
-
SSL_CTX_set_verify(ssl_context, SSL_VERIFY_PEER,
|
1414
|
+
SSL_CTX_set_verify(ssl_context, SSL_VERIFY_PEER, nullptr);
|
1407
1415
|
/* TODO(jboeuf): Add revocation verification. */
|
1408
1416
|
|
1409
1417
|
*factory = impl;
|
@@ -1414,11 +1422,11 @@ static tsi_ssl_handshaker_factory_vtable server_handshaker_factory_vtable = {
|
|
1414
1422
|
tsi_ssl_server_handshaker_factory_destroy};
|
1415
1423
|
|
1416
1424
|
tsi_result tsi_create_ssl_server_handshaker_factory(
|
1417
|
-
const tsi_ssl_pem_key_cert_pair
|
1418
|
-
size_t num_key_cert_pairs, const char
|
1419
|
-
int force_client_auth, const char
|
1420
|
-
const char
|
1421
|
-
tsi_ssl_server_handshaker_factory
|
1425
|
+
const tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs,
|
1426
|
+
size_t num_key_cert_pairs, const char* pem_client_root_certs,
|
1427
|
+
int force_client_auth, const char* cipher_suites,
|
1428
|
+
const char** alpn_protocols, uint16_t num_alpn_protocols,
|
1429
|
+
tsi_ssl_server_handshaker_factory** factory) {
|
1422
1430
|
return tsi_create_ssl_server_handshaker_factory_ex(
|
1423
1431
|
pem_key_cert_pairs, num_key_cert_pairs, pem_client_root_certs,
|
1424
1432
|
force_client_auth ? TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
|
@@ -1427,32 +1435,33 @@ tsi_result tsi_create_ssl_server_handshaker_factory(
|
|
1427
1435
|
}
|
1428
1436
|
|
1429
1437
|
tsi_result tsi_create_ssl_server_handshaker_factory_ex(
|
1430
|
-
const tsi_ssl_pem_key_cert_pair
|
1431
|
-
size_t num_key_cert_pairs, const char
|
1438
|
+
const tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs,
|
1439
|
+
size_t num_key_cert_pairs, const char* pem_client_root_certs,
|
1432
1440
|
tsi_client_certificate_request_type client_certificate_request,
|
1433
|
-
const char
|
1434
|
-
uint16_t num_alpn_protocols, tsi_ssl_server_handshaker_factory
|
1435
|
-
tsi_ssl_server_handshaker_factory
|
1441
|
+
const char* cipher_suites, const char** alpn_protocols,
|
1442
|
+
uint16_t num_alpn_protocols, tsi_ssl_server_handshaker_factory** factory) {
|
1443
|
+
tsi_ssl_server_handshaker_factory* impl = nullptr;
|
1436
1444
|
tsi_result result = TSI_OK;
|
1437
1445
|
size_t i = 0;
|
1438
1446
|
|
1439
1447
|
gpr_once_init(&init_openssl_once, init_openssl);
|
1440
1448
|
|
1441
|
-
if (factory ==
|
1442
|
-
*factory =
|
1443
|
-
if (num_key_cert_pairs == 0 || pem_key_cert_pairs ==
|
1449
|
+
if (factory == nullptr) return TSI_INVALID_ARGUMENT;
|
1450
|
+
*factory = nullptr;
|
1451
|
+
if (num_key_cert_pairs == 0 || pem_key_cert_pairs == nullptr) {
|
1444
1452
|
return TSI_INVALID_ARGUMENT;
|
1445
1453
|
}
|
1446
1454
|
|
1447
|
-
impl = gpr_zalloc(sizeof(*impl));
|
1455
|
+
impl = (tsi_ssl_server_handshaker_factory*)gpr_zalloc(sizeof(*impl));
|
1448
1456
|
tsi_ssl_handshaker_factory_init(&impl->base);
|
1449
1457
|
impl->base.vtable = &server_handshaker_factory_vtable;
|
1450
1458
|
|
1451
|
-
impl->ssl_contexts =
|
1459
|
+
impl->ssl_contexts =
|
1460
|
+
(SSL_CTX**)gpr_zalloc(num_key_cert_pairs * sizeof(SSL_CTX*));
|
1452
1461
|
impl->ssl_context_x509_subject_names =
|
1453
|
-
gpr_zalloc(num_key_cert_pairs * sizeof(tsi_peer));
|
1454
|
-
if (impl->ssl_contexts ==
|
1455
|
-
impl->ssl_context_x509_subject_names ==
|
1462
|
+
(tsi_peer*)gpr_zalloc(num_key_cert_pairs * sizeof(tsi_peer));
|
1463
|
+
if (impl->ssl_contexts == nullptr ||
|
1464
|
+
impl->ssl_context_x509_subject_names == nullptr) {
|
1456
1465
|
tsi_ssl_handshaker_factory_unref(&impl->base);
|
1457
1466
|
return TSI_OUT_OF_RESOURCES;
|
1458
1467
|
}
|
@@ -1471,7 +1480,7 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
|
|
1471
1480
|
for (i = 0; i < num_key_cert_pairs; i++) {
|
1472
1481
|
do {
|
1473
1482
|
impl->ssl_contexts[i] = SSL_CTX_new(TLSv1_2_method());
|
1474
|
-
if (impl->ssl_contexts[i] ==
|
1483
|
+
if (impl->ssl_contexts[i] == nullptr) {
|
1475
1484
|
gpr_log(GPR_ERROR, "Could not create ssl context.");
|
1476
1485
|
result = TSI_OUT_OF_RESOURCES;
|
1477
1486
|
break;
|
@@ -1480,8 +1489,8 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
|
|
1480
1489
|
&pem_key_cert_pairs[i], cipher_suites);
|
1481
1490
|
if (result != TSI_OK) break;
|
1482
1491
|
|
1483
|
-
if (pem_client_root_certs !=
|
1484
|
-
STACK_OF(X509_NAME)
|
1492
|
+
if (pem_client_root_certs != nullptr) {
|
1493
|
+
STACK_OF(X509_NAME)* root_names = nullptr;
|
1485
1494
|
result = ssl_ctx_load_verification_certs(
|
1486
1495
|
impl->ssl_contexts[i], pem_client_root_certs,
|
1487
1496
|
strlen(pem_client_root_certs), &root_names);
|
@@ -1492,14 +1501,14 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
|
|
1492
1501
|
SSL_CTX_set_client_CA_list(impl->ssl_contexts[i], root_names);
|
1493
1502
|
switch (client_certificate_request) {
|
1494
1503
|
case TSI_DONT_REQUEST_CLIENT_CERTIFICATE:
|
1495
|
-
SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_NONE,
|
1504
|
+
SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_NONE, nullptr);
|
1496
1505
|
break;
|
1497
1506
|
case TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
|
1498
1507
|
SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER,
|
1499
1508
|
NullVerifyCallback);
|
1500
1509
|
break;
|
1501
1510
|
case TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY:
|
1502
|
-
SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER,
|
1511
|
+
SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER, nullptr);
|
1503
1512
|
break;
|
1504
1513
|
case TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
|
1505
1514
|
SSL_CTX_set_verify(
|
@@ -1510,7 +1519,7 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
|
|
1510
1519
|
case TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY:
|
1511
1520
|
SSL_CTX_set_verify(
|
1512
1521
|
impl->ssl_contexts[i],
|
1513
|
-
SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
|
1522
|
+
SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, nullptr);
|
1514
1523
|
break;
|
1515
1524
|
}
|
1516
1525
|
/* TODO(jboeuf): Add revocation verification. */
|
@@ -1546,16 +1555,16 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
|
|
1546
1555
|
|
1547
1556
|
/* --- tsi_ssl utils. --- */
|
1548
1557
|
|
1549
|
-
int tsi_ssl_peer_matches_name(const tsi_peer
|
1558
|
+
int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) {
|
1550
1559
|
size_t i = 0;
|
1551
1560
|
size_t san_count = 0;
|
1552
|
-
const tsi_peer_property
|
1561
|
+
const tsi_peer_property* cn_property = nullptr;
|
1553
1562
|
int like_ip = looks_like_ip_address(name);
|
1554
1563
|
|
1555
1564
|
/* Check the SAN first. */
|
1556
1565
|
for (i = 0; i < peer->property_count; i++) {
|
1557
|
-
const tsi_peer_property
|
1558
|
-
if (property->name ==
|
1566
|
+
const tsi_peer_property* property = &peer->properties[i];
|
1567
|
+
if (property->name == nullptr) continue;
|
1559
1568
|
if (strcmp(property->name,
|
1560
1569
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) {
|
1561
1570
|
san_count++;
|
@@ -1577,7 +1586,7 @@ int tsi_ssl_peer_matches_name(const tsi_peer *peer, const char *name) {
|
|
1577
1586
|
}
|
1578
1587
|
|
1579
1588
|
/* If there's no SAN, try the CN, but only if its not like an IP Address */
|
1580
|
-
if (san_count == 0 && cn_property !=
|
1589
|
+
if (san_count == 0 && cn_property != nullptr && !like_ip) {
|
1581
1590
|
if (does_entry_match_name(cn_property->value.data,
|
1582
1591
|
cn_property->value.length, name)) {
|
1583
1592
|
return 1;
|
@@ -1588,13 +1597,13 @@ int tsi_ssl_peer_matches_name(const tsi_peer *peer, const char *name) {
|
|
1588
1597
|
}
|
1589
1598
|
|
1590
1599
|
/* --- Testing support. --- */
|
1591
|
-
const tsi_ssl_handshaker_factory_vtable
|
1592
|
-
tsi_ssl_handshaker_factory
|
1593
|
-
tsi_ssl_handshaker_factory_vtable
|
1594
|
-
GPR_ASSERT(factory !=
|
1595
|
-
GPR_ASSERT(factory->vtable !=
|
1600
|
+
const tsi_ssl_handshaker_factory_vtable* tsi_ssl_handshaker_factory_swap_vtable(
|
1601
|
+
tsi_ssl_handshaker_factory* factory,
|
1602
|
+
tsi_ssl_handshaker_factory_vtable* new_vtable) {
|
1603
|
+
GPR_ASSERT(factory != nullptr);
|
1604
|
+
GPR_ASSERT(factory->vtable != nullptr);
|
1596
1605
|
|
1597
|
-
const tsi_ssl_handshaker_factory_vtable
|
1606
|
+
const tsi_ssl_handshaker_factory_vtable* orig_vtable = factory->vtable;
|
1598
1607
|
factory->vtable = new_vtable;
|
1599
1608
|
return orig_vtable;
|
1600
1609
|
}
|