Skip to content

Commit

Permalink
Merge pull request #289 from EventStore/add-certificates-in-http-fall…
Browse files Browse the repository at this point in the history
…back-handler

DEV-92 - Add certificate in HTTP fallback handler
  • Loading branch information
thefringeninja authored Feb 29, 2024
2 parents 5bd189a + 6bb1999 commit ad51ce6
Showing 1 changed file with 8 additions and 3 deletions.
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;
}

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

0 comments on commit ad51ce6

Please sign in to comment.