ArturKarbone / HttpsDemoInNETCore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Https in .NET Core

This is a demo repository for my blog post.

Create Certificate

Either launch these commands

$cert = New-SelfSignedCertificate -Subject localhost -DnsName localhost -FriendlyName ".NET Core dev certificate" -KeyUsage DigitalSignature -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1") 
Export-Certificate -Cert $cert -FilePath dotnet.core.dev.cer
Import-Certificate -FilePath dotnet.core.dev.cer -CertStoreLocation cert:/CurrentUser/Root

or execute the PowerShell script provided in this repo

./create.certificate.ps

##Consume Certificate

IIS

Will be available among provided certificates in "Binding" section

Kestrel

Via kestrel options configuration:

 var host = new WebHostBuilder()
                .UseKestrel(options => {
                    var cr = new X509Certificate2("./Certificates/dotnet.core.dev.cer");
                    options.UseHttps(cr);
                })

About


Languages

Language:C# 90.0%Language:PowerShell 10.0%