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?
2
Answers
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.
The above error message indicates a problem with SSL certificate validation, the SSL certificate used by your application was not recognized as valid because it was signed by an untrusted certificate authority (CA).
If you are using a self-signed certificate and experiencing SSL verification issues on your local computer, it may be because the certificate is not trusted by default. To resolve this issue, you need to manually add the self-signed certificate to the Trusted Root Certification Authorities store on the local computer. You can try the following steps:
Add.
Add/Remove Snap-in window.
Certification Authorities > Certificates.
wizard to import the self-signed certificate.
Reference link: Adding the self-signed certificate as trusted