diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index da5deced72..10cd86865f 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -113,9 +113,9 @@ if(WITH_OTLP_HTTP_SSL_PREVIEW) endif() endif() -if (WITH_OTLP_GRPC_MTLS_PREVIEW) +if (WITH_OTLP_GRPC_SSL_MTLS_PREVIEW) target_compile_definitions(opentelemetry_api - INTERFACE ENABLE_OTLP_GRPC_MTLS_PREVIEW) + INTERFACE ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW) endif() if(WITH_METRICS_EXEMPLAR_PREVIEW) diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h index 779a21aeab..01ac5b43f2 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h @@ -29,7 +29,7 @@ struct OtlpGrpcExporterOptions // SSL encryption. std::string ssl_credentials_cacert_as_string = GetOtlpDefaultSslCertificateString(); -#ifdef ENABLE_OTLP_GRPC_MTLS_PREVIEW +#ifdef ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW // At most one of ssl_client_key_* should be non-empty. If use_ssl_credentials, they will // be read to allow for mTLS. std::string ssl_client_key_path = GetOtlpDefaultTracesSslClientKeyPath(); diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index a14f624d51..6952ea0422 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -69,17 +69,17 @@ std::shared_ptr OtlpGrpcClient::MakeChannel(const OtlpGrpcExporte grpc_arguments.SetUserAgentPrefix(options.user_agent); if (options.use_ssl_credentials) { - grpc::SslCredentialsOptions ssl_opts = { - .pem_root_certs = GetFileContentsOrInMemoryContents( - options.ssl_credentials_cacert_path, - options.ssl_credentials_cacert_as_string), -#if ENABLE_OTLP_GRPC_MTLS_PREVIEW - .pem_private_key = GetFileContentsOrInMemoryContents( - options.ssl_client_key_path, - options.ssl_client_key_string), - .pem_cert_chain = GetFileContentsOrInMemoryContents( - options.ssl_client_cert_path, - options.ssl_client_cert_string) + grpc::SslCredentialsOptions ssl_opts; + ssl_opts.pem_root_certs = GetFileContentsOrInMemoryContents( + options.ssl_credentials_cacert_path, + options.ssl_credentials_cacert_as_string); +#if ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW + ssl_opts.pem_private_key = GetFileContentsOrInMemoryContents( + options.ssl_client_key_path, + options.ssl_client_key_string); + ssl_opts.pem_cert_chain = GetFileContentsOrInMemoryContents( + options.ssl_client_cert_path, + options.ssl_client_cert_string); #endif }; channel =