Skip to content

Commit ee8caae

Browse files
committed
CA Cert was not actually being checked
1 parent 039e83d commit ee8caae

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,26 @@ private async Task<HttpResponseMessage> SendHttpRequest(HttpRequestMessage httpR
100100
{
101101
chain.ChainPolicy.CustomTrustStore.Add(caCert);
102102
}
103-
if (cert != null)
103+
if (cert == null)
104104
{
105-
// Rebuild the chain with added certs
106-
return chain.Build(cert);
105+
return false;
107106
}
108-
return false;
107+
// Rebuild the chain with added certs
108+
if (!chain.Build(cert))
109+
{
110+
return false;
111+
}
112+
113+
bool isValidCA = mailboxConfiguration.serverSideCertCollection
114+
.Any(caCert => caCert.Thumbprint == cert.Issuer);
115+
if (!isValidCA)
116+
{
117+
_logger.LogError("Server certificate is not issued by a trusted CA!");
118+
return false;
119+
}
120+
121+
return true;;
122+
109123
};
110124
}
111125

0 commit comments

Comments
 (0)