I have been running several .Net 6 APIs in Linux Docker in my local development environment for my work.
I have been able to get the containerized APIs to communicate with each other after resolving some roadblocks I had with the SSL certificates on the containers. It took me a while to figure that out, but I finally was able to get them to work.
In my local environment, I have a .Net Framework 4.7.2 API running in IIS that one of the containerized API needs to communicate with. That .net Framework API is running in my host machine.
The problem I am facing right now is regarding the SSL certificates. I used the same technique that I used with the other containerized APIs to add the SSL certificates in the containers that require them, but that does not seem to work with this .Net Framework API, I am getting the following error message:
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
2024-07-17 00:01:33 —> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors
2024-07-17 00:01:33 at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
2024-07-17 00:01:33 at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions)
2024-07-17 00:01:33 at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
2024-07-17 00:01:33 at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
2024-07-17 00:01:33 — End of inner exception stack trace —
I had gotten that same error before when I was playing around with the certificates that I am using in the containerized APIs, but was able to fix those by making sure the certificate was actually a valid one. I did the same thing with this other certificate for the .Net Framework API, but that does not seem to be the issue.
I based my certificate creation on this question, specifically the Update 5 from that question using that Powershell script.
As I mentioned, this worked for my containerized .Net 6 APIs image based on Alpine.
I also followed this blog post where I was able to install the certificates in the container.
I was expecting the communication to the host based .Net Framework API to work the same way, but unfortunately did not work for this specific scenario.
Does the SSL protocol has something to do with this since the other APIs are .Net 6 and the troublemaker is .Net Framework?
Any help would be appreciated.