-
Notifications
You must be signed in to change notification settings - Fork 305
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
Move Existing ServerCertificateValidation Classes to Shared #1550
Closed
anoopbabu29
wants to merge
8
commits into
open-telemetry:main
from
anoopbabu29:share-certificate-validation
Closed
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bc33fc3
Saving changes to switch to another branch
anoopbabu29 5a5e782
Fully adjusted move to shared
anoopbabu29 81ace52
Removing shared event source entirely, and using invoked actions for …
anoopbabu29 dab2b61
Merge branch 'main' into share-certificate-validation
anoopbabu29 5158730
Remove unncessary file
anoopbabu29 1fe55dc
Resolving conflict in merge
anoopbabu29 ef63c27
Updated change to fix the AWS Event Source and changed delegate logge…
anoopbabu29 fa08aa6
Merge branch 'main' into share-certificate-validation
vishweshbankwar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
153 changes: 0 additions & 153 deletions
153
src/OpenTelemetry.ResourceDetectors.AWS/Http/ServerCertificateValidationProvider.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#if !NETFRAMEWORK | ||
|
||
using System.Diagnostics.Tracing; | ||
|
||
namespace OpenTelemetry.ResourceDetectors; | ||
|
||
[EventSource(Name = "OpenTelemetry-ResourceDetectors-Http")] | ||
internal class ServerCertificateValidationEventSource : EventSource | ||
{ | ||
public static ServerCertificateValidationEventSource Log = new(); | ||
|
||
[Event(1, Message = "Failed to extract resource attributes in '{0}'.", Level = EventLevel.Warning)] | ||
public void FailedToExtractResourceAttributes(string format, string exception) | ||
{ | ||
this.WriteEvent(3, format, exception); | ||
} | ||
|
||
[Event(2, Message = "Failed to validate certificate in format: '{0}', error: '{1}'.", Level = EventLevel.Warning)] | ||
public void FailedToValidateCertificate(string format, string error) | ||
{ | ||
this.WriteEvent(4, format, error); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#if !NETFRAMEWORK | ||
|
||
using System; | ||
using System.Net.Http; | ||
using OpenTelemetry.Internal; | ||
|
||
namespace OpenTelemetry.ResourceDetectors; | ||
|
||
internal class ServerCertificateValidationHandler | ||
{ | ||
public static HttpClientHandler? Create(string certificateFile) | ||
{ | ||
try | ||
{ | ||
ServerCertificateValidationProvider? serverCertificateValidationProvider = ServerCertificateValidationProvider.FromCertificateFile(certificateFile); | ||
|
||
if (serverCertificateValidationProvider == null) | ||
{ | ||
ServerCertificateValidationEventSource.Log.FailedToValidateCertificate(nameof(ServerCertificateValidationHandler), "Failed to Load the certificate file into trusted collection"); | ||
return null; | ||
} | ||
|
||
var clientHandler = new HttpClientHandler | ||
{ | ||
ServerCertificateCustomValidationCallback = | ||
(sender, x509Certificate2, x509Chain, sslPolicyErrors) => | ||
serverCertificateValidationProvider.ValidationCallback(sender, x509Certificate2, x509Chain, sslPolicyErrors), | ||
}; | ||
return clientHandler; | ||
} | ||
catch (Exception ex) | ||
{ | ||
ServerCertificateValidationEventSource.Log.FailedToExtractResourceAttributes($"{nameof(ServerCertificateValidationHandler)} : Failed to create HttpClientHandler", ex.ToInvariantString()); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
#endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
OpenTelemetry-ResourceDetectors-Http -- is there a component with this name?
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.
No, I have created that as a separate name as a placeholder.
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.
We should not use shared name for the eventsources. It'll cause issues like open-telemetry/opentelemetry-dotnet#4516 (comment)