From 8813a4499533e8621ea5b58fabcee2825b951794 Mon Sep 17 00:00:00 2001 From: Daouda Diakite Date: Thu, 7 Nov 2024 10:20:42 +0100 Subject: [PATCH] Fix http connexion with certificates --- .../ArmoniK.Api.Client.Test/ConfTest.cs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs b/packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs index dd8c7001a..3d903a557 100644 --- a/packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs +++ b/packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs @@ -31,6 +31,7 @@ using ArmoniK.Api.Client.Options; using ArmoniK.Api.Client.Submitter; +using ArmoniK.Api.gRPC.V1; using Microsoft.Extensions.Configuration; @@ -95,16 +96,22 @@ public static async Task RpcCalled(string service_name, certChain, sslPolicyErrors) => { - if (caCert != null) + if (!options.AllowUnsafeConnection) { - certChain.ChainPolicy.ExtraStore.Add(new X509Certificate2(caCert!.GetEncoded())); - certChain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority; - certChain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; + if (caCert != null) + { + certChain.ChainPolicy.ExtraStore.Add(new X509Certificate2(caCert!.GetEncoded())); + certChain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority; + certChain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; + return certChain.Build(cert); + } + + certChain.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag; + certChain.ChainPolicy.RevocationMode = X509RevocationMode.Online; + return certChain.Build(cert); } - - return certChain.Build(cert); + return true; }; - var client = new HttpClient(handler); var call_endpoint = Environment.GetEnvironmentVariable("Http__Endpoint") + "/calls.json"; try