-
Notifications
You must be signed in to change notification settings - Fork 859
[OTLP] Add mTLS Support for OTLP Exporter #6343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsCertificateManager.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsCertificateManager.cs
Outdated
Show resolved
Hide resolved
|
|
||
| // Configure chain policy | ||
| chain.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag; | ||
| chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to support Offline for if a user is running in a closed environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martincostello Does this commit look ok? 7368c9e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the same concern as @martincostello, your commit looks fine with me. Why that's not a part of the PR?
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsCertificateManager.cs
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsCertificateManager.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsHttpClientFactory.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsHttpClientFactory.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMtlsOptions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsCertificateManager.cs
Outdated
Show resolved
Hide resolved
bebeff9 to
4b2dc0b
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6343 +/- ##
==========================================
- Coverage 86.67% 86.12% -0.56%
==========================================
Files 258 261 +3
Lines 11873 12099 +226
==========================================
+ Hits 10291 10420 +129
- Misses 1582 1679 +97
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…ostics Co-authored-by: Martin Costello <martin@martincostello.com>
…null reference Co-authored-by: Martin Costello <martin@martincostello.com>
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsHttpClientFactory.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsHttpClientFactory.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsHttpClientFactory.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMtlsOptions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsCertificateManager.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsCertificateManager.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpMtlsCertificateManager.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
|
@alanwest Could you help change the requested change to approve~? Tyvm! |
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
|
@rajkumar-rangaraj Hi! Any updates? |
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
|
Any updates on this? |
Pending @rajkumar-rangaraj 's reviews. |
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
| /// Gets a value indicating whether mTLS is enabled. | ||
| /// mTLS is considered enabled if at least the client certificate path is provided. | ||
| /// </summary> | ||
| public bool IsEnabled => !string.IsNullOrWhiteSpace(this.ClientCertificatePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user sets only OTEL_EXPORTER_OTLP_CERTIFICATE (CA cert) without a client certificate, the factory returns a plain HttpClient. The custom CA validation is completely ignored.
Users wanting to trust a private CA for server validation (one-way TLS with custom CA) won't get it unless they also provide a client certificate. Changing as below could help.
| public bool IsEnabled => !string.IsNullOrWhiteSpace(this.ClientCertificatePath); | |
| public bool IsEnabled => | |
| !string.IsNullOrWhiteSpace(this.ClientCertificatePath) || | |
| !string.IsNullOrWhiteSpace(this.CaCertificatePath); |
| // Try to load as PKCS#12 first, then as PEM | ||
| try | ||
| { | ||
| #if NET9_0_OR_GREATER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users with password-protected PFX/PKCS#12 keystores cannot use it here. Are you planning to follow up on OTEL_EXPORTER_OTLP_CLIENT_KEY_PASSWORD as follow up?
| return cert; | ||
| } | ||
|
|
||
| private static System.Security.Cryptography.X509Certificates.X509Certificate2 CreateExpiredCertificate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this used anywhere?
|
|
||
| public class OtlpMtlsCertificateManagerTests | ||
| { | ||
| private const string TestCertPem = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
| private const string TestCertPem = | |
| private const string InvalidCertPem= |
|
Please plan to increase the test coverage for these areas.
|
Fixes #2009
Design discussion issue #5918
Changes
This PR adds support for mutual TLS (mTLS) configuration to the OTLP exporter on .NET 8 and later. This allows users to specify certificate paths, enable validation, and inject custom server certificate validation logic.
Key changes include:
OtlpMtlsOptionsclass with properties likeClientCertificatePath,ClientKeyPath,CaCertificatePath,EnableFilePermissionChecks, etc.OtlpMtlsHttpClientFactoryfor creatingHttpClientinstances configured for mTLS.OtlpMtlsCertificateManagerfor certificate loading, validation, and file permission checks.OpenTelemetryProtocolExporterEventSourcefor mTLS events.mTLS support is only enabled for builds targeting
NET8_0_OR_GREATER.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes