diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 2608297e08e..64433fe577e 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Add back support for secure gRPC connections over https. + ([#1804](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1804)) + ## 1.0.0-rc3 Released 2021-Feb-04 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs index c379f477ed4..57df35ae5d6 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs @@ -75,15 +75,25 @@ internal OtlpTraceExporter(OtlpExporterOptions options, OtlpCollector.TraceServi } else { - if (options.Endpoint.Scheme == Uri.UriSchemeHttps) + if (options.Endpoint.Scheme != Uri.UriSchemeHttp && options.Endpoint.Scheme != Uri.UriSchemeHttps) { - throw new NotSupportedException("Https Endpoint is not supported."); + throw new NotSupportedException($"Endpoint URI scheme ({options.Endpoint.Scheme}) is not supported. Currently only \"http\" and \"https\" are supported."); } #if NETSTANDARD2_1 this.channel = GrpcChannel.ForAddress(options.Endpoint); #else - this.channel = new Channel(options.Endpoint.Authority, ChannelCredentials.Insecure); + ChannelCredentials channelCredentials; + if (options.Endpoint.Scheme == Uri.UriSchemeHttps) + { + channelCredentials = new SslCredentials(); + } + else + { + channelCredentials = ChannelCredentials.Insecure; + } + + this.channel = new Channel(options.Endpoint.Authority, channelCredentials); #endif this.traceClient = new OtlpCollector.TraceService.TraceServiceClient(this.channel); }