Skip to content

Commit 039e83d

Browse files
committed
feat: add Bypass Certificate Check Flag
1 parent 2459656 commit 039e83d

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

application/DotNetMeshClient/NHS.Mesh.Client/Clients/MeshConnectClient.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ private async Task<HttpResponseMessage> SendHttpRequest(HttpRequestMessage httpR
8282
handler.SslProtocols = SslProtocols.Tls12;
8383
handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, chain, sslPolicyErrors) =>
8484
{
85-
if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
85+
86+
if(_meshConnectConfiguration.BypassServerCertificateValidation)
87+
{
88+
_logger.LogWarning("Bypassing Server Certificate Validation");
89+
return true;
90+
}
91+
else if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
8692
{
8793
return true; // Everything is fine
8894
}

application/DotNetMeshClient/NHS.Mesh.Client/Configuration/MeshConnectConfiguration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,6 @@ public class MeshConnectConfiguration : IMeshConnectConfiguration
5454
public bool ProxyUseDefaultCredentials { get; set; }
5555
/// <summary>Gets the chunk size in bytes for sending chunked messages 19Mb limit outside of HSCN 100Mb limit within</summary>
5656
public int ChunkSize { get; set; }
57+
/// <summary>Flag if the Servers Certificate is Checked against the CA Chain</summary>
58+
public bool BypassServerCertificateValidation { get; set; }
5759
}

application/DotNetMeshClient/NHS.Mesh.Client/Contracts/Configurations/IMeshConnectConfiguration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,6 @@ public interface IMeshConnectConfiguration
5353
bool ProxyUseDefaultCredentials { get; set; }
5454
/// <summary>Gets the chunk size in bytes for sending chunked messages 19Mb limit outside of HSCN 100Mb limit within</summary>
5555
int ChunkSize { get; set; }
56+
/// <summary>Flag if the Servers Certificate is Checked against the CA Chain</summary>
57+
public bool BypassServerCertificateValidation { get; set; }
5658
}

application/DotNetMeshClient/NHS.Mesh.Client/Extensions/MeshMailboxBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public MeshMailboxBuilder(IServiceCollection services,Action<IMeshConnectConfigu
2828
MeshApiInboxUriPath = "inbox",
2929
MeshApiOutboxUriPath = "outbox",
3030
MeshApiAcknowledgeUriPath = "status/acknowledged",
31-
ChunkSize = 19 * 1024 * 1024// below the 20mb limit for external
31+
ChunkSize = 19 * 1024 * 1024,// below the 20mb limit for external
32+
BypassServerCertificateValidation = false
3233
};
3334

3435
options(_meshConnectConfiguration);

0 commit comments

Comments
 (0)