I have an ASP.NET Core 7 MVC application. It uses an ASP.NET Core Web API. The application is running fine when both API and UI are running from Visual Studio 2022.
If I deploy the UI, or both UI and API, to IIS using "No Managed Code" application pool, the application throws an error
The SSL connection could not be established, see inner exception System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions) at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken) at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
Can anyone assist me in resolving this?
Somehow deploying inside Default Web Site on IIS wasn't working. I created a new self signed certificate, deployed both API and UI on the root as a new website with different port for both apps. Enabled https with the newly created self signed certificate on both the applications and it worked.