Using HTTPS (SSL) in ASP. NET Core Kestrel

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.