Skip to content

Commit 9c32859

Browse files
committed
chore(): Decoupling OTEL_EXPORTER_OTLP_CERTIFICATE from mTLS
1 parent 1080291 commit 9c32859

File tree

10 files changed

+639
-210
lines changed

10 files changed

+639
-210
lines changed

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OpenTelemetryProtocolExporterEventSource.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,5 +325,28 @@ internal void MtlsHttpClientCreationFailed(Exception ex)
325325
Level = EventLevel.Error)]
326326
internal void MtlsHttpClientCreationFailed(string exception) =>
327327
this.WriteEvent(34, exception);
328+
329+
[Event(
330+
35,
331+
Message = "CA configured for server validation. Subject: '{0}'.",
332+
Level = EventLevel.Informational)]
333+
internal void CaCertificateConfigured(string subject) =>
334+
this.WriteEvent(35, subject);
335+
336+
[NonEvent]
337+
internal void SecureHttpClientCreationFailed(Exception ex)
338+
{
339+
if (Log.IsEnabled(EventLevel.Error, EventKeywords.All))
340+
{
341+
this.SecureHttpClientCreationFailed(ex.ToInvariantString());
342+
}
343+
}
344+
345+
[Event(
346+
36,
347+
Message = "Failed to create secure HttpClient. Exception: {0}",
348+
Level = EventLevel.Error)]
349+
internal void SecureHttpClientCreationFailed(string exception) =>
350+
this.WriteEvent(36, exception);
328351
#endif
329352
}

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsCertificateManager.cs renamed to src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpCertificateManager.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
1111

1212
/// <summary>
13-
/// Manages certificate loading, validation, and security checks for mTLS connections.
13+
/// Manages certificate loading, validation, and security checks for TLS connections.
1414
/// </summary>
15-
internal static class OtlpMtlsCertificateManager
15+
/// <remarks>
16+
/// This class provides functionality for both simple server certificate trust
17+
/// (for self-signed certificates) and mTLS client authentication scenarios.
18+
/// </remarks>
19+
internal static class OtlpCertificateManager
1620
{
17-
internal const string CaCertificateType = "CA certificate";
21+
internal const string CaCertificateType = "CA Certificate";
1822
internal const string ClientCertificateType = "Client certificate";
1923
internal const string ClientPrivateKeyType = "Client private key";
2024

@@ -218,6 +222,10 @@ public static bool ValidateCertificateChain(
218222
/// <param name="sslPolicyErrors">The SSL policy errors.</param>
219223
/// <param name="caCertificate">The CA certificate to validate against.</param>
220224
/// <returns>True if the certificate is valid; otherwise, false.</returns>
225+
/// <remarks>
226+
/// This method is used to validate server certificates against a CA.
227+
/// Common use case: connecting to a server with a self-signed certificate.
228+
/// </remarks>
221229
internal static bool ValidateServerCertificate(
222230
X509Certificate2 serverCert,
223231
X509Chain chain,

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsHttpClientFactory.cs

Lines changed: 0 additions & 167 deletions
This file was deleted.

0 commit comments

Comments
 (0)