diff --git a/packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs b/packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs index dd8c7001a..8b2947a22 100644 --- a/packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs +++ b/packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs @@ -28,6 +28,7 @@ using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; using System.Threading.Tasks; +using System.Net.Security; using ArmoniK.Api.Client.Options; using ArmoniK.Api.Client.Submitter; @@ -95,16 +96,21 @@ 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); + } + + return sslPolicyErrors == SslPolicyErrors.None; } - return certChain.Build(cert); + return true; }; - var client = new HttpClient(handler); var call_endpoint = Environment.GetEnvironmentVariable("Http__Endpoint") + "/calls.json"; try diff --git a/packages/csharp/ArmoniK.Api.Client.Test/ConnectivityTest.cs b/packages/csharp/ArmoniK.Api.Client.Test/ConnectivityTest.cs index b71f86b26..91c6f40b2 100644 --- a/packages/csharp/ArmoniK.Api.Client.Test/ConnectivityTest.cs +++ b/packages/csharp/ArmoniK.Api.Client.Test/ConnectivityTest.cs @@ -43,9 +43,7 @@ public class ConnectivityTests { [SetUp] public void SetUp() - { - options_ = ConfTest.GetChannelOptions(); - } + => options_ = ConfTest.GetChannelOptions(); private GrpcClient? options_;