From 8d95aad50cffbb5742406a5124f5ba79ab60f280 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 10 Mar 2021 10:36:11 -0800 Subject: [PATCH] Channelz security changes - Follow up from #25593 (#25624) --- src/core/lib/channel/channelz.cc | 2 +- test/cpp/end2end/channelz_service_test.cc | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 22279b1c531..d360239e156 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -375,7 +375,7 @@ Json SocketNode::Security::RenderJson() { break; case ModelType::kOther: if (other) { - data["other"] = tls->RenderJson(); + data["other"] = *other; } break; } diff --git a/test/cpp/end2end/channelz_service_test.cc b/test/cpp/end2end/channelz_service_test.cc index 53f0bf58306..3b5aa508c90 100644 --- a/test/cpp/end2end/channelz_service_test.cc +++ b/test/cpp/end2end/channelz_service_test.cc @@ -151,20 +151,17 @@ std::shared_ptr GetChannelCredentials( return InsecureChannelCredentials(); } args->SetSslTargetNameOverride("foo.test.google.fr"); - // TODO(yashykt): Switch to using C++ API once b/173823806 is fixed. - grpc_tls_credentials_options* options = grpc_tls_credentials_options_create(); - grpc_tls_credentials_options_set_certificate_provider( - options, - grpc_core::MakeRefCounted( - ReadFile(kCaCertPath), - ReadTlsIdentityPair(kClientKeyPath, kClientCertPath)) - .get()); + std::vector identity_key_cert_pairs = { + {ReadFile(kClientKeyPath), ReadFile(kClientCertPath)}}; + grpc::experimental::TlsChannelCredentialsOptions options; + options.set_certificate_provider( + std::make_shared( + ReadFile(kCaCertPath), identity_key_cert_pairs)); if (type == CredentialsType::kMtls) { - grpc_tls_credentials_options_watch_identity_key_cert_pairs(options); + options.watch_identity_key_cert_pairs(); } - grpc_tls_credentials_options_watch_root_certs(options); - return std::make_shared( - grpc_tls_credentials_create(options)); + options.watch_root_certs(); + return grpc::experimental::TlsCredentials(options); } std::shared_ptr GetServerCredentials(