diff --git a/src/core/ext/xds/certificate_provider_factory.h b/src/core/ext/xds/certificate_provider_factory.h index 068bddd4ad6..84c219e66bf 100644 --- a/src/core/ext/xds/certificate_provider_factory.h +++ b/src/core/ext/xds/certificate_provider_factory.h @@ -39,6 +39,8 @@ class CertificateProviderFactory { // Name of the type of the CertificateProvider. Unique to each type of // config. virtual const char* name() const = 0; + + virtual std::string ToString() const = 0; }; virtual ~CertificateProviderFactory() = default; diff --git a/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc b/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc index f74d53560af..ef59b894d60 100644 --- a/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc +++ b/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc @@ -164,6 +164,11 @@ const char* GoogleMeshCaCertificateProviderFactory::Config::name() const { return kMeshCaPlugin; } +std::string GoogleMeshCaCertificateProviderFactory::Config::ToString() const { + // TODO(yashykt): To be filled + return "{}"; +} + std::vector GoogleMeshCaCertificateProviderFactory::Config::ParseJsonObjectStsService( const Json::Object& sts_service) { diff --git a/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h b/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h index b0f195d8ffe..f2765d6d80b 100644 --- a/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h +++ b/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h @@ -46,6 +46,8 @@ class GoogleMeshCaCertificateProviderFactory const char* name() const override; + std::string ToString() const override; + const std::string& endpoint() const { return endpoint_; } const StsConfig& sts_config() const { return sts_config_; } diff --git a/src/core/ext/xds/xds_bootstrap.cc b/src/core/ext/xds/xds_bootstrap.cc index e7b75428d66..3daeb73404d 100644 --- a/src/core/ext/xds/xds_bootstrap.cc +++ b/src/core/ext/xds/xds_bootstrap.cc @@ -116,7 +116,18 @@ std::string BootstrapString(const XdsBootstrap& bootstrap) { " server_features=[", absl::StrJoin(bootstrap.server().server_features, ", "), "],\n")); } - parts.push_back(" }\n]"); + parts.push_back(" }\n],\n"); + parts.push_back("certificate_providers={\n"); + for (const auto& entry : bootstrap.certificate_providers()) { + parts.push_back( + absl::StrFormat(" %s={\n" + " plugin_name=%s\n" + " config=%s\n" + " },\n", + entry.first, entry.second.plugin_name, + entry.second.config->ToString())); + } + parts.push_back("}"); return absl::StrJoin(parts, ""); } diff --git a/test/core/xds/certificate_provider_store_test.cc b/test/core/xds/certificate_provider_store_test.cc index b6e1334e8d3..4e31e913ce2 100644 --- a/test/core/xds/certificate_provider_store_test.cc +++ b/test/core/xds/certificate_provider_store_test.cc @@ -50,6 +50,8 @@ class FakeCertificateProviderFactory1 : public CertificateProviderFactory { class Config : public CertificateProviderFactory::Config { public: const char* name() const override { return "fake1"; } + + std::string ToString() const override { return "{}"; } }; const char* name() const override { return "fake1"; } @@ -71,6 +73,8 @@ class FakeCertificateProviderFactory2 : public CertificateProviderFactory { class Config : public CertificateProviderFactory::Config { public: const char* name() const override { return "fake2"; } + + std::string ToString() const override { return "{}"; } }; const char* name() const override { return "fake2"; } diff --git a/test/core/xds/xds_bootstrap_test.cc b/test/core/xds/xds_bootstrap_test.cc index 2a16c98e3e8..596d8233c17 100644 --- a/test/core/xds/xds_bootstrap_test.cc +++ b/test/core/xds/xds_bootstrap_test.cc @@ -17,6 +17,7 @@ #include #include "absl/strings/numbers.h" +#include "absl/strings/str_format.h" #include #include @@ -433,6 +434,14 @@ class FakeCertificateProviderFactory : public CertificateProviderFactory { const char* name() const override { return "fake"; } + std::string ToString() const override { + return absl::StrFormat( + "{\n" + " value=%d" + "}", + value_); + } + private: int value_; };