in ASP. NET core, if you want to use HTTPS to encrypt the transmission of the site in Kestrel, you can
Request a Certificate
This step is not detailed, there are free and charge, after the application will give you a *.pfx end of the document.
Add a NuGet Package
Find in NuGet and then add references in the program Microsoft.AspNetCore.Server.Kestrel.Https
Configuration
Copy the *.pfx end of the file to the Web root of the program, and then modify the Programs.cs file:
public class program{public static void Main (string[] args) { var config = new Configurationbuilder (). Addcommandline (args). Addenvironmentvariables ("Aspnetcore_"). Build (); var host = new Webhostbuilder (). Useconfiguration (config). Usekestrel (Confighttps ()). Usecontentroot ( directory.getcurrentdirectory ()). Useiisintegration (). Usestartup<startup> (). Build (); Host. Run (); } private static action<kestrelserveroptions> Confighttps () { return x = = {var PFXFile = Path.Combine (Directory.GetCurrentDirectory (), "*.pfx"); Password fill in the requested key var certificate = new X509Certificate2 (pfxfile, "password"); X.usehttps (certificate); }; }}
The command-line window then runs dotnet xxx.dll--server.urls https://www.example.com:port.
The above is the whole content of this article, I hope that everyone's learning has helped, but also hope that we support topic.alibabacloud.com.