Skip to content

Commit

Permalink
Fix http connexion with certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiakiteaneo committed Nov 7, 2024
1 parent d201790 commit c394a55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 12 additions & 6 deletions packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,16 +96,21 @@ public static async Task<uint> 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()));

Check warning on line 103 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 103 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 103 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 103 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 103 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.
certChain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority;
certChain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
return certChain.Build(cert);

Check warning on line 106 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'certificate' in 'bool X509Chain.Build(X509Certificate2 certificate)'.

Check warning on line 106 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'certificate' in 'bool X509Chain.Build(X509Certificate2 certificate)'.

Check warning on line 106 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'certificate' in 'bool X509Chain.Build(X509Certificate2 certificate)'.

Check warning on line 106 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'certificate' in 'bool X509Chain.Build(X509Certificate2 certificate)'.

Check warning on line 106 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'certificate' in 'bool X509Chain.Build(X509Certificate2 certificate)'.
}

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
Expand Down
4 changes: 1 addition & 3 deletions packages/csharp/ArmoniK.Api.Client.Test/ConnectivityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public class ConnectivityTests
{
[SetUp]
public void SetUp()
{
options_ = ConfTest.GetChannelOptions();
}
=> options_ = ConfTest.GetChannelOptions();

private GrpcClient? options_;

Expand Down

0 comments on commit c394a55

Please sign in to comment.