grpc 1.83.1 → 1.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +21 -17
  3. data/include/grpc/credentials.h +10 -0
  4. data/include/grpc/grpc_security_constants.h +2 -0
  5. data/include/grpc/impl/channel_arg_names.h +9 -0
  6. data/src/core/call/call_filters.h +4 -2
  7. data/src/core/call/client_call.cc +20 -8
  8. data/src/core/call/client_call.h +4 -0
  9. data/src/core/call/interception_chain.cc +2 -0
  10. data/src/core/call/interception_chain.h +14 -1
  11. data/src/core/call/metadata.cc +1 -3
  12. data/src/core/call/metadata_batch.h +13 -5
  13. data/src/core/call/server_call.cc +31 -14
  14. data/src/core/call/server_call.h +4 -0
  15. data/src/core/channelz/text_encode.cc +9 -4
  16. data/src/core/channelz/v2tov1/convert.cc +2 -2
  17. data/src/core/client_channel/backup_poller.cc +1 -2
  18. data/src/core/client_channel/client_channel.cc +6 -33
  19. data/src/core/client_channel/client_channel_filter.cc +22 -55
  20. data/src/core/client_channel/client_channel_filter.h +2 -2
  21. data/src/core/client_channel/client_channel_service_config.cc +3 -19
  22. data/src/core/client_channel/direct_channel.cc +7 -1
  23. data/src/core/client_channel/direct_channel.h +2 -2
  24. data/src/core/client_channel/load_balanced_call_destination.cc +5 -3
  25. data/src/core/client_channel/retry_filter_legacy_call_data.cc +5 -12
  26. data/src/core/client_channel/subchannel.cc +310 -1058
  27. data/src/core/client_channel/subchannel.h +44 -329
  28. data/src/core/client_channel/subchannel_metrics.cc +48 -0
  29. data/src/core/client_channel/subchannel_metrics.h +60 -0
  30. data/src/core/credentials/call/external/file_external_account_credentials.cc +1 -1
  31. data/src/core/credentials/call/external/url_external_account_credentials.cc +2 -3
  32. data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +8 -24
  33. data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h +3 -6
  34. data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.cc +525 -0
  35. data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.h +138 -0
  36. data/src/core/credentials/call/json_util.h +1 -0
  37. data/src/core/credentials/call/jwt/json_token.cc +10 -2
  38. data/src/core/credentials/call/jwt/jwt_verifier.cc +15 -1
  39. data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +1 -1
  40. data/src/core/credentials/call/oauth2/oauth2_credentials.cc +42 -79
  41. data/src/core/credentials/call/oauth2/oauth2_credentials.h +2 -5
  42. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +52 -31
  43. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.h +21 -8
  44. data/src/core/credentials/transport/google_default/google_default_credentials.cc +3 -4
  45. data/src/core/credentials/transport/ssl/ssl_credentials.cc +59 -72
  46. data/src/core/credentials/transport/ssl/ssl_credentials.h +9 -8
  47. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +12 -6
  48. data/src/core/credentials/transport/ssl/ssl_security_connector.h +4 -4
  49. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -18
  50. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +9 -6
  51. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +45 -56
  52. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +5 -4
  53. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.h +26 -0
  54. data/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +1 -1
  55. data/src/core/credentials/transport/tls/load_system_roots.h +2 -6
  56. data/src/core/credentials/transport/tls/load_system_roots_fallback.cc +2 -4
  57. data/src/core/credentials/transport/tls/load_system_roots_supported.cc +13 -15
  58. data/src/core/credentials/transport/tls/load_system_roots_supported.h +3 -2
  59. data/src/core/credentials/transport/tls/load_system_roots_windows.cc +5 -8
  60. data/src/core/credentials/transport/tls/spiffe_utils.cc +1 -1
  61. data/src/core/credentials/transport/tls/ssl_utils.cc +39 -28
  62. data/src/core/credentials/transport/tls/ssl_utils.h +12 -49
  63. data/src/core/credentials/transport/tls/tls_security_connector.cc +48 -33
  64. data/src/core/credentials/transport/tls/tls_security_connector.h +31 -10
  65. data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +15 -11
  66. data/src/core/ext/filters/http/http_filters_plugin.cc +20 -9
  67. data/src/core/ext/filters/rbac/rbac_filter.cc +43 -21
  68. data/src/core/ext/filters/rbac/rbac_filter.h +21 -3
  69. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +2 -2
  70. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
  71. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -20
  72. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +32 -67
  73. data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -0
  74. data/src/core/ext/transport/chttp2/transport/flow_control.h +78 -4
  75. data/src/core/ext/transport/chttp2/transport/frame.h +2 -0
  76. data/src/core/ext/transport/chttp2/transport/frame_data.cc +3 -4
  77. data/src/core/ext/transport/chttp2/transport/goaway.h +7 -0
  78. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +5 -3
  79. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -1
  80. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +141 -130
  81. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +22 -22
  82. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +402 -269
  83. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +80 -49
  84. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +1 -2
  85. data/src/core/ext/transport/chttp2/transport/http2_status.h +38 -37
  86. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +178 -5
  87. data/src/core/ext/transport/chttp2/transport/http2_transport.h +345 -5
  88. data/src/core/ext/transport/chttp2/transport/parsing.cc +5 -5
  89. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +3 -2
  90. data/src/core/ext/transport/chttp2/transport/ping_promise.h +25 -5
  91. data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +3 -4
  92. data/src/core/ext/transport/chttp2/transport/read_context.h +30 -3
  93. data/src/core/ext/transport/chttp2/transport/stream.h +65 -23
  94. data/src/core/ext/transport/chttp2/transport/writing.cc +0 -3
  95. data/src/core/ext/transport/inproc/inproc_transport.cc +1 -5
  96. data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +4 -17
  97. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb.h +1912 -0
  98. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.c +300 -0
  99. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.h +37 -0
  100. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb.h +187 -0
  101. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.c +64 -0
  102. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.h +31 -0
  103. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb.h +2362 -0
  104. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.c +556 -0
  105. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.h +47 -0
  106. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb.h +5 -5
  107. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.c +3 -3
  108. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.h +5 -5
  109. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.c +453 -0
  110. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.h +67 -0
  111. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.c +142 -0
  112. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.h +37 -0
  113. data/src/core/ext/upbdefs-gen/grpc/channelz/v1/channelz.upbdefs.c +715 -0
  114. data/src/core/ext/upbdefs-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upbdefs.h +44 -44
  115. data/src/core/filter/auth/server_auth_filter.cc +2 -3
  116. data/src/core/filter/composite/composite_filter.cc +45 -33
  117. data/src/core/filter/composite/composite_filter.h +5 -4
  118. data/src/core/filter/ext_proc/ext_proc_filter.cc +224 -0
  119. data/src/core/filter/ext_proc/ext_proc_filter.h +155 -0
  120. data/src/core/filter/ext_proc/ext_proc_messages.cc +701 -0
  121. data/src/core/filter/ext_proc/ext_proc_messages.h +297 -0
  122. data/src/core/filter/filter_args.h +13 -2
  123. data/src/core/handshaker/http_connect/http_proxy_mapper.cc +30 -3
  124. data/src/core/handshaker/security/security_handshaker.cc +9 -6
  125. data/src/core/lib/channel/channel_stack.cc +3 -0
  126. data/src/core/lib/channel/channel_stack.h +2 -0
  127. data/src/core/lib/channel/channel_stack_builder_impl.cc +1 -2
  128. data/src/core/lib/channel/promise_based_filter.cc +132 -20
  129. data/src/core/lib/channel/promise_based_filter.h +42 -12
  130. data/src/core/lib/compression/compression_internal.cc +4 -5
  131. data/src/core/lib/debug/trace_flags.cc +8 -0
  132. data/src/core/lib/debug/trace_flags.h +3 -0
  133. data/src/core/lib/event_engine/ares_resolver.cc +54 -50
  134. data/src/core/lib/event_engine/ares_resolver.h +3 -2
  135. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +3 -3
  136. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +4 -10
  137. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +74 -33
  138. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +4 -4
  139. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +6 -2
  140. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +3 -0
  141. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +3 -0
  142. data/src/core/lib/event_engine/windows/windows_endpoint.cc +1 -3
  143. data/src/core/lib/experiments/experiments.cc +60 -96
  144. data/src/core/lib/experiments/experiments.h +34 -50
  145. data/src/core/lib/iomgr/cfstream_handle.cc +2 -6
  146. data/src/core/lib/iomgr/endpoint_cfstream.cc +3 -10
  147. data/src/core/lib/iomgr/error.cc +2 -6
  148. data/src/core/lib/iomgr/error_cfstream.cc +1 -1
  149. data/src/core/lib/iomgr/ev_poll_posix.cc +5 -9
  150. data/src/core/lib/iomgr/event_engine_shims/closure.cc +1 -1
  151. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +1 -2
  152. data/src/core/lib/iomgr/event_engine_shims/tcp_client.cc +1 -2
  153. data/src/core/lib/iomgr/iomgr_posix.cc +0 -4
  154. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +0 -4
  155. data/src/core/lib/iomgr/iomgr_windows.cc +0 -4
  156. data/src/core/lib/iomgr/socket_factory_posix.h +1 -1
  157. data/src/core/lib/iomgr/socket_utils_posix.cc +3 -0
  158. data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
  159. data/src/core/lib/iomgr/systemd_utils.cc +0 -1
  160. data/src/core/lib/iomgr/tcp_client.h +1 -1
  161. data/src/core/lib/iomgr/tcp_posix.cc +23 -15
  162. data/src/core/lib/iomgr/tcp_server.h +1 -1
  163. data/src/core/lib/iomgr/tcp_server_posix.cc +2 -3
  164. data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -1
  165. data/src/core/lib/iomgr/tcp_server_windows.cc +0 -1
  166. data/src/core/lib/iomgr/tcp_windows.cc +5 -10
  167. data/src/core/lib/iomgr/unix_sockets_posix.cc +2 -4
  168. data/src/core/lib/iomgr/unix_sockets_posix.h +3 -1
  169. data/src/core/lib/iomgr/vsock.h +3 -1
  170. data/src/core/lib/resource_quota/memory_quota.cc +1 -1
  171. data/src/core/lib/security/authorization/rbac_policy.cc +139 -56
  172. data/src/core/lib/security/authorization/rbac_policy.h +21 -3
  173. data/src/core/lib/surface/call.cc +3 -9
  174. data/src/core/lib/surface/call_utils.h +113 -0
  175. data/src/core/lib/surface/channel_create.cc +1 -1
  176. data/src/core/lib/surface/channel_create.h +0 -2
  177. data/src/core/lib/surface/channel_init.cc +77 -38
  178. data/src/core/lib/surface/channel_init.h +30 -16
  179. data/src/core/lib/surface/filter_stack_call.cc +5 -10
  180. data/src/core/lib/surface/init.cc +13 -27
  181. data/src/core/lib/surface/version.cc +1 -1
  182. data/src/core/lib/transport/error_utils.cc +0 -27
  183. data/src/core/lib/transport/error_utils.h +0 -16
  184. data/src/core/lib/transport/transport.h +7 -5
  185. data/src/core/load_balancing/pick_first/pick_first.cc +2 -0
  186. data/src/core/load_balancing/rls/rls.cc +28 -11
  187. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +33 -42
  188. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.h +0 -2
  189. data/src/core/load_balancing/xds/cds.cc +3 -1
  190. data/src/core/load_balancing/xds/xds_cluster_impl.cc +0 -1
  191. data/src/core/mitigation_engine/mitigation.h +14 -5
  192. data/src/core/mitigation_engine/mitigation_engine.h +7 -3
  193. data/src/core/mitigation_engine/mitigation_provider.h +2 -1
  194. data/src/core/plugin_registry/grpc_plugin_registry.cc +39 -8
  195. data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.cc → dns_resolver.cc} +42 -41
  196. data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.h → dns_resolver.h} +8 -5
  197. data/src/core/resolver/dns/{event_engine/service_config_helper.cc → service_config_helper.cc} +1 -1
  198. data/src/core/resolver/dns/{event_engine/service_config_helper.h → service_config_helper.h} +3 -3
  199. data/src/core/resolver/endpoint_addresses.h +3 -0
  200. data/src/core/resolver/google_c2p/google_c2p_resolver.cc +2 -1
  201. data/src/core/resolver/xds/xds_resolver.cc +35 -9
  202. data/src/core/server/server.cc +2 -6
  203. data/src/core/server/server_config_selector.h +18 -3
  204. data/src/core/server/server_config_selector_filter.cc +178 -91
  205. data/src/core/server/server_config_selector_filter.h +58 -3
  206. data/src/core/server/xds_server_config_fetcher.cc +196 -129
  207. data/src/core/server/xds_server_config_fetcher.h +49 -0
  208. data/src/core/server/xds_server_config_fetcher_legacy.cc +41 -37
  209. data/src/core/telemetry/histogram.h +94 -14
  210. data/src/core/telemetry/instrument.cc +179 -74
  211. data/src/core/telemetry/instrument.h +78 -30
  212. data/src/core/telemetry/metrics.h +5 -0
  213. data/src/core/{resolver/dns/dns_resolver_plugin.h → telemetry/telemetry_label.h} +12 -8
  214. data/src/core/tsi/alts/crypt/aes_gcm.cc +10 -13
  215. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -2
  216. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +3 -1
  217. data/src/core/tsi/ssl_telemetry_utils.cc +216 -259
  218. data/src/core/tsi/ssl_telemetry_utils.h +12 -2
  219. data/src/core/tsi/ssl_transport_security.cc +238 -80
  220. data/src/core/tsi/ssl_transport_security.h +63 -33
  221. data/src/core/tsi/tls_telemetry.cc +31 -0
  222. data/src/core/tsi/tls_telemetry.h +47 -0
  223. data/src/core/tsi/transport_security.cc +2 -2
  224. data/src/core/tsi/transport_security.h +1 -1
  225. data/src/core/tsi/transport_security_interface.h +1 -1
  226. data/src/core/{resolver/dns/native/dns_resolver.h → util/address_sorting_init.cc} +21 -8
  227. data/src/core/{resolver/dns/c_ares/grpc_ares_wrapper_posix.cc → util/address_sorting_init.h} +7 -8
  228. data/src/core/util/http_client/httpcli.cc +16 -53
  229. data/src/core/util/http_client/httpcli.h +0 -7
  230. data/src/core/util/http_client/httpcli_security_connector.cc +13 -8
  231. data/src/core/util/linux/cpu.cc +1 -1
  232. data/src/core/util/load_file.cc +3 -9
  233. data/src/core/util/load_file.h +3 -4
  234. data/src/core/util/matchers.h +8 -0
  235. data/src/core/util/posix/cpu.cc +1 -1
  236. data/src/core/util/status_helper.cc +0 -20
  237. data/src/core/util/status_helper.h +3 -14
  238. data/src/core/xds/grpc/xds_audit_logger_registry.cc +51 -31
  239. data/src/core/xds/grpc/xds_audit_logger_registry.h +17 -3
  240. data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -10
  241. data/src/core/xds/grpc/xds_bootstrap_grpc.h +8 -6
  242. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +488 -0
  243. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.h +97 -0
  244. data/src/core/xds/grpc/xds_certificate_provider.cc +7 -7
  245. data/src/core/xds/grpc/xds_client_grpc.cc +4 -8
  246. data/src/core/xds/grpc/xds_client_grpc.h +0 -4
  247. data/src/core/xds/grpc/xds_cluster.h +1 -0
  248. data/src/core/xds/grpc/xds_cluster_parser.cc +1 -5
  249. data/src/core/xds/grpc/xds_cluster_parser.h +0 -2
  250. data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +0 -2
  251. data/src/core/xds/grpc/xds_cluster_specifier_plugin.h +0 -2
  252. data/src/core/xds/grpc/xds_common_types.cc +0 -91
  253. data/src/core/xds/grpc/xds_common_types.h +1 -47
  254. data/src/core/xds/grpc/xds_common_types_parser.cc +84 -378
  255. data/src/core/xds/grpc/xds_common_types_parser.h +9 -11
  256. data/src/core/xds/grpc/xds_endpoint_parser.cc +0 -2
  257. data/src/core/xds/grpc/xds_grpc_service_parser.cc +177 -0
  258. data/src/core/{resolver/dns/c_ares/dns_resolver_ares.h → xds/grpc/xds_grpc_service_parser.h} +14 -9
  259. data/src/core/xds/grpc/xds_http_composite_filter.cc +26 -21
  260. data/src/core/xds/grpc/xds_http_composite_filter.h +4 -3
  261. data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +418 -0
  262. data/src/core/xds/grpc/xds_http_ext_proc_filter.h +89 -0
  263. data/src/core/xds/grpc/xds_http_fault_filter.cc +9 -12
  264. data/src/core/xds/grpc/xds_http_fault_filter.h +1 -4
  265. data/src/core/xds/grpc/xds_http_filter.cc +2 -1
  266. data/src/core/xds/grpc/xds_http_filter.h +6 -5
  267. data/src/core/xds/grpc/xds_http_filter_registry.cc +10 -127
  268. data/src/core/xds/grpc/xds_http_filter_registry.h +7 -59
  269. data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +13 -14
  270. data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +3 -2
  271. data/src/core/xds/grpc/xds_http_rbac_filter.cc +403 -25
  272. data/src/core/xds/grpc/xds_http_rbac_filter.h +1 -3
  273. data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +8 -13
  274. data/src/core/xds/grpc/xds_http_stateful_session_filter.h +1 -4
  275. data/src/core/xds/grpc/xds_lb_policy_registry.cc +0 -292
  276. data/src/core/xds/grpc/xds_lb_policy_registry.h +7 -3
  277. data/src/core/xds/grpc/xds_listener.cc +2 -0
  278. data/src/core/xds/grpc/xds_listener.h +5 -0
  279. data/src/core/xds/grpc/xds_listener_parser.cc +16 -11
  280. data/src/core/xds/grpc/xds_matcher_parse.h +3 -1
  281. data/src/core/xds/grpc/xds_metadata_parser.cc +6 -1
  282. data/src/core/xds/grpc/xds_metadata_parser.h +2 -0
  283. data/src/core/xds/grpc/xds_route_config.cc +2 -0
  284. data/src/core/xds/grpc/xds_route_config.h +3 -1
  285. data/src/core/xds/grpc/xds_route_config_parser.cc +13 -79
  286. data/src/core/xds/grpc/xds_route_config_parser.h +0 -3
  287. data/src/core/xds/grpc/xds_routing.cc +116 -69
  288. data/src/core/xds/grpc/xds_routing.h +19 -8
  289. data/src/core/xds/grpc/xds_tls_context.cc +117 -0
  290. data/src/core/xds/grpc/xds_tls_context.h +76 -0
  291. data/src/core/xds/grpc/xds_tls_context_parser.cc +275 -0
  292. data/src/core/xds/grpc/xds_tls_context_parser.h +35 -0
  293. data/src/core/xds/grpc/xds_transport_grpc.cc +41 -38
  294. data/src/core/xds/grpc/xds_transport_grpc.h +4 -2
  295. data/src/ruby/ext/grpc/rb_call.c +26 -15
  296. data/src/ruby/ext/grpc/rb_completion_queue.c +6 -5
  297. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  298. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  299. data/src/ruby/lib/grpc/version.rb +1 -1
  300. data/src/ruby/pb/test/client.rb +5 -4
  301. data/src/ruby/spec/call_spec.rb +14 -0
  302. data/src/ruby/spec/generic/server_interceptors_spec.rb +3 -6
  303. metadata +50 -35
  304. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +0 -716
  305. data/src/core/lib/iomgr/resolve_address.cc +0 -59
  306. data/src/core/lib/iomgr/resolve_address.h +0 -125
  307. data/src/core/lib/iomgr/resolve_address_impl.h +0 -58
  308. data/src/core/lib/iomgr/resolve_address_posix.cc +0 -184
  309. data/src/core/lib/iomgr/resolve_address_posix.h +0 -78
  310. data/src/core/lib/iomgr/resolve_address_windows.cc +0 -169
  311. data/src/core/lib/iomgr/resolve_address_windows.h +0 -76
  312. data/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +0 -781
  313. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +0 -93
  314. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +0 -203
  315. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +0 -838
  316. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +0 -1237
  317. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +0 -130
  318. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +0 -35
  319. data/src/core/resolver/dns/dns_resolver_plugin.cc +0 -64
  320. data/src/core/resolver/dns/native/dns_resolver.cc +0 -173
  321. data/src/core/util/json/json_util.cc +0 -101
  322. data/src/core/util/json/json_util.h +0 -163
@@ -50,19 +50,18 @@
50
50
  //
51
51
 
52
52
  grpc_ssl_credentials::grpc_ssl_credentials(
53
- const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
53
+ std::string pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
54
54
  const grpc_ssl_verify_peer_options* verify_options) {
55
- build_config(pem_root_certs, pem_key_cert_pair, verify_options);
55
+ build_config(std::move(pem_root_certs), pem_key_cert_pair, verify_options);
56
56
  // Use default (e.g. OS) root certificates if the user did not pass any root
57
57
  // certificates.
58
- if (config_.pem_root_certs == nullptr) {
59
- const char* pem_root_certs =
58
+ if (config_.pem_root_certs.empty()) {
59
+ absl::string_view pem_root_certs =
60
60
  grpc_core::DefaultSslRootStore::GetPemRootCerts();
61
- if (pem_root_certs == nullptr) {
61
+ if (pem_root_certs.empty()) {
62
62
  LOG(ERROR) << "Could not get default pem root certs.";
63
63
  } else {
64
- char* default_roots = gpr_strdup(pem_root_certs);
65
- config_.pem_root_certs = default_roots;
64
+ config_.pem_root_certs = std::string(pem_root_certs);
66
65
  root_store_ = grpc_core::DefaultSslRootStore::GetRootStore();
67
66
  }
68
67
  } else {
@@ -75,7 +74,6 @@ grpc_ssl_credentials::grpc_ssl_credentials(
75
74
  }
76
75
 
77
76
  grpc_ssl_credentials::~grpc_ssl_credentials() {
78
- gpr_free(config_.pem_root_certs);
79
77
  if (config_.verify_options.verify_peer_destruct != nullptr) {
80
78
  config_.verify_options.verify_peer_destruct(
81
79
  config_.verify_options.verify_peer_callback_userdata);
@@ -87,7 +85,7 @@ grpc_core::RefCountedPtr<grpc_channel_security_connector>
87
85
  grpc_ssl_credentials::create_security_connector(
88
86
  grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
89
87
  const char* target, grpc_core::ChannelArgs* args) {
90
- if (config_.pem_root_certs == nullptr) {
88
+ if (config_.pem_root_certs.empty()) {
91
89
  LOG(ERROR) << "No root certs in config. Client-side security connector "
92
90
  "must have root certs.";
93
91
  return nullptr;
@@ -146,14 +144,14 @@ grpc_core::UniqueTypeName grpc_ssl_credentials::Type() {
146
144
  }
147
145
 
148
146
  void grpc_ssl_credentials::build_config(
149
- const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
147
+ std::string pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
150
148
  const grpc_ssl_verify_peer_options* verify_options) {
151
- config_.pem_root_certs = gpr_strdup(pem_root_certs);
149
+ config_.pem_root_certs = std::move(pem_root_certs);
152
150
  if (pem_key_cert_pair != nullptr) {
153
151
  GRPC_CHECK_NE(pem_key_cert_pair->private_key, nullptr);
154
152
  GRPC_CHECK_NE(pem_key_cert_pair->cert_chain, nullptr);
155
- config_.pem_key_cert_pair.cert_chain = pem_key_cert_pair->cert_chain;
156
- config_.pem_key_cert_pair.private_key = pem_key_cert_pair->private_key;
153
+ config_.pem_key_cert_pair = grpc_core::PemKeyCertPair(
154
+ pem_key_cert_pair->private_key, pem_key_cert_pair->cert_chain);
157
155
  }
158
156
  if (verify_options != nullptr) {
159
157
  memcpy(&config_.verify_options, verify_options,
@@ -175,7 +173,7 @@ void grpc_ssl_credentials::set_max_tls_version(
175
173
  }
176
174
 
177
175
  grpc_security_status grpc_ssl_credentials::InitializeClientHandshakerFactory(
178
- const grpc_ssl_config* config, const char* pem_root_certs,
176
+ const grpc_ssl_config* config, std::string pem_root_certs,
179
177
  const tsi_ssl_root_certs_store* root_store,
180
178
  tsi_ssl_session_cache* ssl_session_cache,
181
179
  tsi_ssl_client_handshaker_factory** handshaker_factory) {
@@ -186,15 +184,16 @@ grpc_security_status grpc_ssl_credentials::InitializeClientHandshakerFactory(
186
184
  }
187
185
 
188
186
  bool has_key_cert_pair =
189
- !grpc_core::IsPrivateKeyEmpty(config->pem_key_cert_pair.private_key) &&
190
- !config->pem_key_cert_pair.cert_chain.empty();
187
+ !grpc_core::IsPrivateKeyEmpty(config->pem_key_cert_pair.private_key()) &&
188
+ !config->pem_key_cert_pair.cert_chain().empty();
191
189
  tsi_ssl_client_handshaker_options options;
192
- if (pem_root_certs == nullptr) {
190
+ if (pem_root_certs.empty()) {
193
191
  LOG(ERROR) << "Handshaker factory creation failed. pem_root_certs cannot "
194
- "be nullptr";
192
+ "be empty";
195
193
  return GRPC_SECURITY_ERROR;
196
194
  }
197
- options.root_cert_info = std::make_shared<tsi::RootCertInfo>(pem_root_certs);
195
+ options.root_cert_info =
196
+ std::make_shared<tsi::RootCertInfo>(std::move(pem_root_certs));
198
197
  options.root_store = root_store;
199
198
  options.alpn_protocols =
200
199
  grpc_fill_alpn_protocol_strings(&options.num_alpn_protocols);
@@ -229,6 +228,7 @@ grpc_channel_credentials* grpc_ssl_credentials_create(
229
228
  << ")";
230
229
  GRPC_CHECK_EQ(reserved, nullptr);
231
230
 
231
+ if (pem_root_certs == nullptr) pem_root_certs = "";
232
232
  return new grpc_ssl_credentials(
233
233
  pem_root_certs, pem_key_cert_pair,
234
234
  reinterpret_cast<const grpc_ssl_verify_peer_options*>(verify_options));
@@ -244,6 +244,7 @@ grpc_channel_credentials* grpc_ssl_credentials_create_ex(
244
244
  << ")";
245
245
  GRPC_CHECK_EQ(reserved, nullptr);
246
246
 
247
+ if (pem_root_certs == nullptr) pem_root_certs = "";
247
248
  return new grpc_ssl_credentials(pem_root_certs, pem_key_cert_pair,
248
249
  verify_options);
249
250
  }
@@ -253,9 +254,11 @@ grpc_channel_credentials* grpc_ssl_credentials_create_ex(
253
254
  //
254
255
 
255
256
  struct grpc_ssl_server_credentials_options {
256
- grpc_ssl_client_certificate_request_type client_certificate_request;
257
- grpc_ssl_server_certificate_config* certificate_config;
258
- grpc_ssl_server_certificate_config_fetcher* certificate_config_fetcher;
257
+ grpc_ssl_client_certificate_request_type client_certificate_request =
258
+ GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
259
+ std::unique_ptr<grpc_ssl_server_certificate_config> certificate_config;
260
+ std::unique_ptr<grpc_ssl_server_certificate_config_fetcher>
261
+ certificate_config_fetcher;
259
262
  };
260
263
 
261
264
  grpc_ssl_server_credentials::grpc_ssl_server_credentials(
@@ -271,9 +274,6 @@ grpc_ssl_server_credentials::grpc_ssl_server_credentials(
271
274
  }
272
275
  }
273
276
 
274
- grpc_ssl_server_credentials::~grpc_ssl_server_credentials() {
275
- gpr_free(config_.pem_root_certs);
276
- }
277
277
  grpc_core::RefCountedPtr<grpc_server_security_connector>
278
278
  grpc_ssl_server_credentials::create_security_connector(
279
279
  const grpc_core::ChannelArgs& args) {
@@ -285,29 +285,29 @@ grpc_core::UniqueTypeName grpc_ssl_server_credentials::Type() {
285
285
  return kFactory.Create();
286
286
  }
287
287
 
288
- std::vector<tsi_ssl_pem_key_cert_pair> grpc_convert_grpc_to_tsi_cert_pairs(
288
+ grpc_core::PemKeyCertPairList grpc_convert_grpc_to_key_cert_pairs(
289
289
  const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
290
290
  size_t num_key_cert_pairs) {
291
- std::vector<tsi_ssl_pem_key_cert_pair> tsi_pairs;
291
+ grpc_core::PemKeyCertPairList key_cert_pairs;
292
292
  if (num_key_cert_pairs > 0) {
293
293
  GRPC_CHECK_NE(pem_key_cert_pairs, nullptr);
294
294
  }
295
295
  for (size_t i = 0; i < num_key_cert_pairs; i++) {
296
296
  GRPC_CHECK_NE(pem_key_cert_pairs[i].private_key, nullptr);
297
297
  GRPC_CHECK_NE(pem_key_cert_pairs[i].cert_chain, nullptr);
298
- tsi_pairs.emplace_back(pem_key_cert_pairs[i].private_key,
299
- pem_key_cert_pairs[i].cert_chain);
298
+ key_cert_pairs.emplace_back(pem_key_cert_pairs[i].private_key,
299
+ pem_key_cert_pairs[i].cert_chain);
300
300
  }
301
- return tsi_pairs;
301
+ return key_cert_pairs;
302
302
  }
303
303
 
304
304
  void grpc_ssl_server_credentials::build_config(
305
- const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
305
+ std::string pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
306
306
  size_t num_key_cert_pairs,
307
307
  grpc_ssl_client_certificate_request_type client_certificate_request) {
308
308
  config_.client_certificate_request = client_certificate_request;
309
- config_.pem_root_certs = gpr_strdup(pem_root_certs);
310
- config_.pem_key_cert_pairs = grpc_convert_grpc_to_tsi_cert_pairs(
309
+ config_.pem_root_certs = std::move(pem_root_certs);
310
+ config_.pem_key_cert_pairs = grpc_convert_grpc_to_key_cert_pairs(
311
311
  pem_key_cert_pairs, num_key_cert_pairs);
312
312
  }
313
313
 
@@ -326,9 +326,8 @@ grpc_ssl_server_certificate_config* grpc_ssl_server_certificate_config_create(
326
326
  const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
327
327
  size_t num_key_cert_pairs) {
328
328
  grpc_ssl_server_certificate_config* config =
329
- static_cast<grpc_ssl_server_certificate_config*>(
330
- gpr_zalloc(sizeof(grpc_ssl_server_certificate_config)));
331
- config->pem_root_certs = gpr_strdup(pem_root_certs);
329
+ new grpc_ssl_server_certificate_config;
330
+ if (pem_root_certs != nullptr) config->pem_root_certs = pem_root_certs;
332
331
  if (num_key_cert_pairs > 0) {
333
332
  GRPC_CHECK_NE(pem_key_cert_pairs, nullptr);
334
333
  config->pem_key_cert_pairs = static_cast<grpc_ssl_pem_key_cert_pair*>(
@@ -346,32 +345,31 @@ grpc_ssl_server_certificate_config* grpc_ssl_server_certificate_config_create(
346
345
  return config;
347
346
  }
348
347
 
348
+ grpc_ssl_server_certificate_config::~grpc_ssl_server_certificate_config() {
349
+ for (size_t i = 0; i < num_key_cert_pairs; i++) {
350
+ gpr_free(const_cast<char*>(pem_key_cert_pairs[i].private_key));
351
+ gpr_free(const_cast<char*>(pem_key_cert_pairs[i].cert_chain));
352
+ }
353
+ gpr_free(pem_key_cert_pairs);
354
+ }
355
+
349
356
  void grpc_ssl_server_certificate_config_destroy(
350
357
  grpc_ssl_server_certificate_config* config) {
351
- if (config == nullptr) return;
352
- for (size_t i = 0; i < config->num_key_cert_pairs; i++) {
353
- gpr_free(const_cast<char*>(config->pem_key_cert_pairs[i].private_key));
354
- gpr_free(const_cast<char*>(config->pem_key_cert_pairs[i].cert_chain));
355
- }
356
- gpr_free(config->pem_key_cert_pairs);
357
- gpr_free(config->pem_root_certs);
358
- gpr_free(config);
358
+ delete config;
359
359
  }
360
360
 
361
361
  grpc_ssl_server_credentials_options*
362
362
  grpc_ssl_server_credentials_create_options_using_config(
363
363
  grpc_ssl_client_certificate_request_type client_certificate_request,
364
364
  grpc_ssl_server_certificate_config* config) {
365
- grpc_ssl_server_credentials_options* options = nullptr;
366
365
  if (config == nullptr) {
367
366
  LOG(ERROR) << "Certificate config must not be NULL.";
368
- goto done;
367
+ return nullptr;
369
368
  }
370
- options = static_cast<grpc_ssl_server_credentials_options*>(
371
- gpr_zalloc(sizeof(grpc_ssl_server_credentials_options)));
369
+ grpc_ssl_server_credentials_options* options =
370
+ new grpc_ssl_server_credentials_options;
372
371
  options->client_certificate_request = client_certificate_request;
373
- options->certificate_config = config;
374
- done:
372
+ options->certificate_config.reset(config);
375
373
  return options;
376
374
  }
377
375
 
@@ -384,17 +382,13 @@ grpc_ssl_server_credentials_create_options_using_config_fetcher(
384
382
  return nullptr;
385
383
  }
386
384
 
387
- grpc_ssl_server_certificate_config_fetcher* fetcher =
388
- static_cast<grpc_ssl_server_certificate_config_fetcher*>(
389
- gpr_zalloc(sizeof(grpc_ssl_server_certificate_config_fetcher)));
390
- fetcher->cb = cb;
391
- fetcher->user_data = user_data;
392
-
393
385
  grpc_ssl_server_credentials_options* options =
394
- static_cast<grpc_ssl_server_credentials_options*>(
395
- gpr_zalloc(sizeof(grpc_ssl_server_credentials_options)));
386
+ new grpc_ssl_server_credentials_options;
396
387
  options->client_certificate_request = client_certificate_request;
397
- options->certificate_config_fetcher = fetcher;
388
+ options->certificate_config_fetcher =
389
+ std::make_unique<grpc_ssl_server_certificate_config_fetcher>();
390
+ options->certificate_config_fetcher->cb = cb;
391
+ options->certificate_config_fetcher->user_data = user_data;
398
392
 
399
393
  return options;
400
394
  }
@@ -435,37 +429,30 @@ grpc_server_credentials* grpc_ssl_server_credentials_create_ex(
435
429
 
436
430
  grpc_server_credentials* grpc_ssl_server_credentials_create_with_options(
437
431
  grpc_ssl_server_credentials_options* options) {
438
- grpc_server_credentials* retval = nullptr;
432
+ std::unique_ptr<grpc_ssl_server_credentials_options> options_owner(options);
439
433
 
440
434
  if (options == nullptr) {
441
435
  LOG(ERROR) << "Invalid options trying to create SSL server credentials.";
442
- goto done;
436
+ return nullptr;
443
437
  }
444
438
 
445
439
  if (options->certificate_config == nullptr &&
446
440
  options->certificate_config_fetcher == nullptr) {
447
441
  LOG(ERROR) << "SSL server credentials options must specify either "
448
442
  "certificate config or fetcher.";
449
- goto done;
443
+ return nullptr;
450
444
  } else if (options->certificate_config_fetcher != nullptr &&
451
445
  options->certificate_config_fetcher->cb == nullptr) {
452
446
  LOG(ERROR) << "Certificate config fetcher callback must not be NULL.";
453
- goto done;
447
+ return nullptr;
454
448
  }
455
449
 
456
- retval = new grpc_ssl_server_credentials(*options);
457
-
458
- done:
459
- grpc_ssl_server_credentials_options_destroy(options);
460
- return retval;
450
+ return new grpc_ssl_server_credentials(*options);
461
451
  }
462
452
 
463
453
  void grpc_ssl_server_credentials_options_destroy(
464
454
  grpc_ssl_server_credentials_options* o) {
465
- if (o == nullptr) return;
466
- gpr_free(o->certificate_config_fetcher);
467
- grpc_ssl_server_certificate_config_destroy(o->certificate_config);
468
- gpr_free(o);
455
+ delete o;
469
456
  }
470
457
 
471
458
  namespace {
@@ -37,7 +37,7 @@
37
37
 
38
38
  class grpc_ssl_credentials : public grpc_channel_credentials {
39
39
  public:
40
- grpc_ssl_credentials(const char* pem_root_certs,
40
+ grpc_ssl_credentials(std::string pem_root_certs,
41
41
  grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
42
42
  const grpc_ssl_verify_peer_options* verify_options);
43
43
 
@@ -64,7 +64,7 @@ class grpc_ssl_credentials : public grpc_channel_credentials {
64
64
  static_cast<const grpc_channel_credentials*>(this), other);
65
65
  }
66
66
 
67
- void build_config(const char* pem_root_certs,
67
+ void build_config(std::string pem_root_certs,
68
68
  grpc_ssl_pem_key_cert_pair* pem_key_cert_pair,
69
69
  const grpc_ssl_verify_peer_options* verify_options);
70
70
 
@@ -74,7 +74,7 @@ class grpc_ssl_credentials : public grpc_channel_credentials {
74
74
  // that there is a session cache. If a session cache is used, a new handshaker
75
75
  // factory will be created and used that contains that session cache.
76
76
  grpc_security_status InitializeClientHandshakerFactory(
77
- const grpc_ssl_config* config, const char* pem_root_certs,
77
+ const grpc_ssl_config* config, std::string pem_root_certs,
78
78
  const tsi_ssl_root_certs_store* root_store,
79
79
  tsi_ssl_session_cache* ssl_session_cache,
80
80
  tsi_ssl_client_handshaker_factory** handshaker_factory);
@@ -88,19 +88,20 @@ class grpc_ssl_credentials : public grpc_channel_credentials {
88
88
  struct grpc_ssl_server_certificate_config {
89
89
  grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs = nullptr;
90
90
  size_t num_key_cert_pairs = 0;
91
- char* pem_root_certs = nullptr;
91
+ std::string pem_root_certs;
92
+
93
+ ~grpc_ssl_server_certificate_config();
92
94
  };
93
95
 
94
96
  struct grpc_ssl_server_certificate_config_fetcher {
95
97
  grpc_ssl_server_certificate_config_callback cb = nullptr;
96
- void* user_data;
98
+ void* user_data = nullptr;
97
99
  };
98
100
 
99
101
  class grpc_ssl_server_credentials final : public grpc_server_credentials {
100
102
  public:
101
103
  explicit grpc_ssl_server_credentials(
102
104
  const grpc_ssl_server_credentials_options& options);
103
- ~grpc_ssl_server_credentials() override;
104
105
 
105
106
  grpc_core::RefCountedPtr<grpc_server_security_connector>
106
107
  create_security_connector(const grpc_core::ChannelArgs& /* args */) override;
@@ -129,7 +130,7 @@ class grpc_ssl_server_credentials final : public grpc_server_credentials {
129
130
 
130
131
  private:
131
132
  void build_config(
132
- const char* pem_root_certs,
133
+ std::string pem_root_certs,
133
134
  grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs,
134
135
  grpc_ssl_client_certificate_request_type client_certificate_request);
135
136
 
@@ -137,7 +138,7 @@ class grpc_ssl_server_credentials final : public grpc_server_credentials {
137
138
  grpc_ssl_server_certificate_config_fetcher certificate_config_fetcher_;
138
139
  };
139
140
 
140
- std::vector<tsi_ssl_pem_key_cert_pair> grpc_convert_grpc_to_tsi_cert_pairs(
141
+ grpc_core::PemKeyCertPairList grpc_convert_grpc_to_key_cert_pairs(
141
142
  const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs,
142
143
  size_t num_key_cert_pairs);
143
144
 
@@ -26,6 +26,7 @@
26
26
  #include <string>
27
27
  #include <utility>
28
28
 
29
+ #include "src/core/client_channel/client_channel_args.h"
29
30
  #include "src/core/credentials/transport/ssl/ssl_credentials.h"
30
31
  #include "src/core/credentials/transport/tls/ssl_utils.h"
31
32
  #include "src/core/credentials/transport/transport_credentials.h"
@@ -109,6 +110,10 @@ class grpc_ssl_channel_security_connector final
109
110
  grpc_core::RefCountedPtr<grpc_core::CollectionScope> collection_scope =
110
111
  stats_plugin_group != nullptr ? stats_plugin_group->GetCollectionScope()
111
112
  : nullptr;
113
+ std::string backend_service(
114
+ args.GetString(GRPC_ARG_BACKEND_SERVICE).value_or(""));
115
+ std::string locality(args.GetString(GRPC_ARG_LB_LOCALITY).value_or(""));
116
+ std::string target(args.GetString(GRPC_ARG_SERVER_URI).value_or(""));
112
117
  tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
113
118
  client_handshaker_factory_,
114
119
  overridden_target_name_.empty() ? target_name_.c_str()
@@ -116,7 +121,8 @@ class grpc_ssl_channel_security_connector final
116
121
  /*network_bio_buf_size=*/0,
117
122
  /*ssl_bio_buf_size=*/0,
118
123
  args.GetOwnedString(GRPC_ARG_TRANSPORT_PROTOCOLS),
119
- std::move(collection_scope), &tsi_hs);
124
+ std::move(collection_scope), std::move(target), std::move(locality),
125
+ std::move(backend_service), &tsi_hs);
120
126
  if (result != TSI_OK) {
121
127
  LOG(ERROR) << "Handshaker creation failed with error "
122
128
  << tsi_result_to_string(result);
@@ -246,9 +252,9 @@ class grpc_ssl_server_security_connector
246
252
  grpc_fill_alpn_protocol_strings(&num_alpn_protocols);
247
253
  }
248
254
  tsi_ssl_server_handshaker_options options;
249
- options.pem_key_cert_pairs =
255
+ options.key_cert_pairs_or_selector =
250
256
  server_credentials->config().pem_key_cert_pairs;
251
- if (server_credentials->config().pem_root_certs != nullptr) {
257
+ if (!server_credentials->config().pem_root_certs.empty()) {
252
258
  options.root_cert_info = std::make_shared<tsi::RootCertInfo>(
253
259
  server_credentials->config().pem_root_certs);
254
260
  }
@@ -367,11 +373,11 @@ class grpc_ssl_server_security_connector
367
373
  tsi_ssl_server_handshaker_factory* new_handshaker_factory = nullptr;
368
374
  const grpc_ssl_server_credentials* server_creds =
369
375
  static_cast<const grpc_ssl_server_credentials*>(this->server_creds());
370
- GRPC_DCHECK_NE(config->pem_root_certs, nullptr);
376
+ GRPC_DCHECK(!config->pem_root_certs.empty());
371
377
  tsi_ssl_server_handshaker_options options;
372
- options.pem_key_cert_pairs = grpc_convert_grpc_to_tsi_cert_pairs(
378
+ options.key_cert_pairs_or_selector = grpc_convert_grpc_to_key_cert_pairs(
373
379
  config->pem_key_cert_pairs, config->num_key_cert_pairs);
374
- if (config->pem_root_certs != nullptr) {
380
+ if (!config->pem_root_certs.empty()) {
375
381
  options.root_cert_info =
376
382
  std::make_shared<tsi::RootCertInfo>(config->pem_root_certs);
377
383
  }
@@ -32,8 +32,8 @@
32
32
  #include "src/core/util/ref_counted_ptr.h"
33
33
 
34
34
  struct grpc_ssl_config {
35
- tsi_ssl_pem_key_cert_pair pem_key_cert_pair;
36
- char* pem_root_certs;
35
+ grpc_core::PemKeyCertPair pem_key_cert_pair;
36
+ std::string pem_root_certs;
37
37
  verify_peer_options verify_options;
38
38
  grpc_tls_version min_tls_version = grpc_tls_version::TLS1_2;
39
39
  grpc_tls_version max_tls_version = grpc_tls_version::TLS1_3;
@@ -62,8 +62,8 @@ grpc_ssl_channel_security_connector_create(
62
62
 
63
63
  // Config for ssl servers.
64
64
  struct grpc_ssl_server_config {
65
- std::vector<tsi_ssl_pem_key_cert_pair> pem_key_cert_pairs;
66
- char* pem_root_certs = nullptr;
65
+ grpc_core::PemKeyCertPairList pem_key_cert_pairs;
66
+ std::string pem_root_certs;
67
67
  grpc_ssl_client_certificate_request_type client_certificate_request =
68
68
  GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
69
69
  grpc_tls_version min_tls_version = grpc_tls_version::TLS1_2;
@@ -20,6 +20,7 @@
20
20
  #include <grpc/grpc_security.h>
21
21
  #include <grpc/support/port_platform.h>
22
22
 
23
+ #include "src/core/credentials/transport/tls/ssl_utils.h"
23
24
  #include "src/core/tsi/ssl_transport_security.h"
24
25
  #include "src/core/util/grpc_check.h"
25
26
  #include "absl/status/status.h"
@@ -30,8 +31,9 @@ bool grpc_tls_certificate_distributor::CertificateInfo::AreRootsEmpty() {
30
31
 
31
32
  void grpc_tls_certificate_distributor::SetKeyMaterials(
32
33
  const std::string& cert_name, std::shared_ptr<tsi::RootCertInfo> roots,
33
- std::optional<grpc_core::PemKeyCertPairList> pem_key_cert_pairs) {
34
- GRPC_CHECK(roots != nullptr || pem_key_cert_pairs.has_value());
34
+ std::optional<grpc_core::KeyCertPairsOrSelector>
35
+ key_cert_pairs_or_selector) {
36
+ GRPC_CHECK(roots != nullptr || key_cert_pairs_or_selector.has_value());
35
37
  grpc_core::MutexLock lock(&mu_);
36
38
  auto& cert_info = certificate_info_map_[cert_name];
37
39
  if (roots != nullptr) {
@@ -42,23 +44,26 @@ void grpc_tls_certificate_distributor::SetKeyMaterials(
42
44
  const auto watcher_it = watchers_.find(watcher_ptr);
43
45
  GRPC_CHECK(watcher_it != watchers_.end());
44
46
  GRPC_CHECK(watcher_it->second.root_cert_name.has_value());
45
- std::optional<grpc_core::PemKeyCertPairList> pem_key_cert_pairs_to_report;
46
- if (pem_key_cert_pairs.has_value() &&
47
+ std::optional<grpc_core::KeyCertPairsOrSelector>
48
+ key_cert_pairs_or_selector_to_report;
49
+ if (key_cert_pairs_or_selector.has_value() &&
47
50
  watcher_it->second.identity_cert_name == cert_name) {
48
- pem_key_cert_pairs_to_report = pem_key_cert_pairs;
51
+ key_cert_pairs_or_selector_to_report = key_cert_pairs_or_selector;
49
52
  } else if (watcher_it->second.identity_cert_name.has_value()) {
50
53
  auto& identity_cert_info =
51
54
  certificate_info_map_[*watcher_it->second.identity_cert_name];
52
- if (!identity_cert_info.pem_key_cert_pairs.empty()) {
53
- pem_key_cert_pairs_to_report = identity_cert_info.pem_key_cert_pairs;
55
+ if (!grpc_core::IsKeyCertPairsOrSelectorEmpty(
56
+ identity_cert_info.key_cert_pairs_or_selector)) {
57
+ key_cert_pairs_or_selector_to_report =
58
+ identity_cert_info.key_cert_pairs_or_selector;
54
59
  }
55
60
  }
56
61
  watcher_ptr->OnCertificatesChanged(
57
- roots, std::move(pem_key_cert_pairs_to_report));
62
+ roots, std::move(key_cert_pairs_or_selector_to_report));
58
63
  }
59
64
  cert_info.roots = roots;
60
65
  }
61
- if (pem_key_cert_pairs.has_value()) {
66
+ if (key_cert_pairs_or_selector.has_value()) {
62
67
  // Successful credential updates will clear any pre-existing error.
63
68
  cert_info.SetIdentityError(absl::OkStatus());
64
69
  for (const auto watcher_ptr : cert_info.identity_cert_watchers) {
@@ -79,9 +84,10 @@ void grpc_tls_certificate_distributor::SetKeyMaterials(
79
84
  }
80
85
  }
81
86
  watcher_ptr->OnCertificatesChanged(std::move(roots_to_report),
82
- pem_key_cert_pairs);
87
+ key_cert_pairs_or_selector);
83
88
  }
84
- cert_info.pem_key_cert_pairs = std::move(*pem_key_cert_pairs);
89
+ cert_info.key_cert_pairs_or_selector =
90
+ std::move(*key_cert_pairs_or_selector);
85
91
  }
86
92
  }
87
93
 
@@ -97,7 +103,8 @@ bool grpc_tls_certificate_distributor::HasKeyCertPairs(
97
103
  grpc_core::MutexLock lock(&mu_);
98
104
  const auto it = certificate_info_map_.find(identity_cert_name);
99
105
  return it != certificate_info_map_.end() &&
100
- !it->second.pem_key_cert_pairs.empty();
106
+ !grpc_core::IsKeyCertPairsOrSelectorEmpty(
107
+ it->second.key_cert_pairs_or_selector);
101
108
  };
102
109
 
103
110
  void grpc_tls_certificate_distributor::SetErrorForCert(
@@ -190,7 +197,8 @@ void grpc_tls_certificate_distributor::WatchTlsCertificates(
190
197
  watchers_[watcher_ptr] = {std::move(watcher), root_cert_name,
191
198
  identity_cert_name};
192
199
  std::shared_ptr<tsi::RootCertInfo> updated_roots;
193
- std::optional<grpc_core::PemKeyCertPairList> updated_identity_pairs;
200
+ std::optional<grpc_core::KeyCertPairsOrSelector>
201
+ updated_key_cert_pairs_or_selector;
194
202
  grpc_error_handle root_error;
195
203
  grpc_error_handle identity_error;
196
204
  if (root_cert_name.has_value()) {
@@ -213,8 +221,10 @@ void grpc_tls_certificate_distributor::WatchTlsCertificates(
213
221
  cert_info.identity_cert_watchers.insert(watcher_ptr);
214
222
  identity_error = cert_info.identity_cert_error;
215
223
  // Empty credentials will be treated as no updates.
216
- if (!cert_info.pem_key_cert_pairs.empty()) {
217
- updated_identity_pairs = cert_info.pem_key_cert_pairs;
224
+ if (!grpc_core::IsKeyCertPairsOrSelectorEmpty(
225
+ cert_info.key_cert_pairs_or_selector)) {
226
+ updated_key_cert_pairs_or_selector =
227
+ cert_info.key_cert_pairs_or_selector;
218
228
  }
219
229
  }
220
230
  // Notify this watcher if the certs it is watching already had some
@@ -222,9 +232,10 @@ void grpc_tls_certificate_distributor::WatchTlsCertificates(
222
232
  // occurred while trying to fetch the latest cert, but the updated_*_certs
223
233
  // should always be valid. So we will send the updates regardless of
224
234
  // *_cert_error.
225
- if (updated_roots != nullptr || updated_identity_pairs.has_value()) {
226
- watcher_ptr->OnCertificatesChanged(updated_roots,
227
- std::move(updated_identity_pairs));
235
+ if (updated_roots != nullptr ||
236
+ updated_key_cert_pairs_or_selector.has_value()) {
237
+ watcher_ptr->OnCertificatesChanged(
238
+ updated_roots, std::move(updated_key_cert_pairs_or_selector));
228
239
  }
229
240
  // Notify this watcher if the certs it is watching already had some
230
241
  // errors.
@@ -62,7 +62,8 @@ struct grpc_tls_certificate_distributor
62
62
  // pairs.
63
63
  virtual void OnCertificatesChanged(
64
64
  std::shared_ptr<tsi::RootCertInfo> roots,
65
- std::optional<grpc_core::PemKeyCertPairList> key_cert_pairs) = 0;
65
+ std::optional<grpc_core::KeyCertPairsOrSelector>
66
+ key_cert_pairs_or_selector) = 0;
66
67
 
67
68
  // Handles an error that occurs while attempting to fetch certificate data.
68
69
  // Note that if a watcher sees an error, it simply means the Provider is
@@ -88,9 +89,10 @@ struct grpc_tls_certificate_distributor
88
89
  // @param roots The content of the roots, either the pem root certificates or
89
90
  // the SpiffeBundleMap.
90
91
  // @param pem_key_cert_pairs The content of identity key-cert pairs.
91
- void SetKeyMaterials(
92
- const std::string& cert_name, std::shared_ptr<tsi::RootCertInfo> roots,
93
- std::optional<grpc_core::PemKeyCertPairList> pem_key_cert_pairs);
92
+ void SetKeyMaterials(const std::string& cert_name,
93
+ std::shared_ptr<tsi::RootCertInfo> roots,
94
+ std::optional<grpc_core::KeyCertPairsOrSelector>
95
+ key_cert_pairs_or_selector);
94
96
 
95
97
  bool HasRootCerts(const std::string& root_cert_name);
96
98
 
@@ -177,8 +179,9 @@ struct grpc_tls_certificate_distributor
177
179
  struct CertificateInfo {
178
180
  // The contents of the root certificates.
179
181
  std::shared_ptr<tsi::RootCertInfo> roots;
180
- // The contents of the identity key-certificate pairs.
181
- grpc_core::PemKeyCertPairList pem_key_cert_pairs;
182
+ // The contents of the identity key-certificate pairs or a certificate
183
+ // selector.
184
+ grpc_core::KeyCertPairsOrSelector key_cert_pairs_or_selector;
182
185
  // TODO(gtcooke94) Swap to using absl::StatusOr<>
183
186
  // https://github.com/grpc/grpc/pull/39708/files#r2144014200 The root cert
184
187
  // reloading error propagated by the caller.