Skip to content
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

DEV-92 - Add certificate in HTTP fallback handler #289

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/EventStore.Client/HttpFallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ internal HttpFallback (EventStoreClientSettings settings) {
_defaultCredentials = settings.DefaultCredentials;

var handler = new HttpClientHandler();
if (!settings.ConnectivitySettings.Insecure && !settings.ConnectivitySettings.TlsVerifyCert) {
if (!settings.ConnectivitySettings.Insecure) {
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.ServerCertificateCustomValidationCallback = (_, _, _, _) => true;

if (settings.ConnectivitySettings.TlsCaFile != null)
handler.ClientCertificates.Add(settings.ConnectivitySettings.TlsCaFile);

if (!settings.ConnectivitySettings.TlsVerifyCert)
handler.ServerCertificateCustomValidationCallback = (_, _, _, _) => true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor quibble. Could be

handler.ServerCertificateCustomValidationCallback = delegate { return  true; };

since we do not care about the parameters but the functionality is the same.

}

_httpClient = new HttpClient(handler);
if (settings.DefaultDeadline.HasValue) {
_httpClient.Timeout = settings.DefaultDeadline.Value;
Expand Down
Loading