Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net core 2.1.3 ssl error

Tags:

c#

ssl

.net-core

Hello guys right now I am using .net core 2.1.3 when I install webapi project by "dotnet new webapi" when I try to open by firefox or chrome it gives me this error

HttpsConnectionAdapter[1] Failed to authenticate HTTPS connection. System.IO.IOException: Authentication failed because the remote party has closed the transport stream.

like image 743
Seyfullah C Avatar asked Jul 12 '18 17:07

Seyfullah C


People also ask

What is UseHsts in .NET core?

It is recommended for an ASP.NET Core application to use: - HTTPS Redirection Middleware (UseHttpsRedirection) to redirect HTTP requests to HTTPS. - HSTS Middleware (UseHsts) to send HTTP Strict Transport Security Protocol (HSTS) headers to clients. Remediation.

What is UseHttpsRedirection .NET core?

UseHttpsRedirection(); is a single line code, which you have to write under Configure method to secure . NET Core solutions. Moreover, you don't always have to configure this middleware, as most ASP.NET web app templates, such as MVC, come with it by default enabled with it.


1 Answers

I face the same problem. In my test, it seems the problem using Kestrel with SSL. (other IISExpress is OK)

It look like the SSL is not ready yet, when you browse it.

The workaround for me is just simply change the position in launchSetting:

 "applicationUrl": "https://localhost:443;http://localhost:80"

to

 "applicationUrl": "http://localhost:80;https://localhost:443"

With app.UseHttpsRedirection(); in Startup.cs

it will go to port 80 first and then redirect to port 443

like image 168
Marcus Wong Avatar answered Oct 07 '22 01:10

Marcus Wong