sev*_*rin 3 c# asp.net ssl iis-express asp.net-core
我们在本地IIS Express上运行带有ASP.NET Core的Web API.我们正在使用hosts-file中配置的自定义域名.
这很好用,但我们必须时不时地手动信任Chrome中的网站,因此我们希望将IIS Express设置为使用我们的SSL证书.
IIS Express在launchSettings.json中配置:
"iisExpress": {
"applicationUrl": "http://applocal.ourdomain.com:5000",
"sslPort": 44300
}
Run Code Online (Sandbox Code Playgroud)
我们如何配置IIS Express以使用我们的SSL证书?
首先制作一个新证书并替换主机名,确保其在本地计算机上制作。
电源外壳:
New-SelfSignedCertificate -NotBefore (Get-Date) -NotAfter (Get-Date).AddYears(1) -Subject "YOUR.DOMAIN.NAME" -KeyAlgorithm "RSA" -KeyLength 2048 -HashAlgorithm "SHA256" -CertStoreLocation "Cert:\LocalMachine\My" -KeyUsage KeyEncipherment -FriendlyName "HTTPS PROJECTNAME development certificate" -TextExtension @("2.5.29.19={critical}{text}","2.5.29.37={critical}{text}1.3.6.1.5.5.7.3.1","2.5.29.17={critical}{text}DNS=YOUR.DOMAIN.NAME")
现在我们需要将其复制到本地计算机的受信任证书中:打开“mmc”为本地计算机(非个人用户)的证书管理器添加管理单元找到证书并将其复制到“受信任的根证书颁发机构”

接下来您需要告诉 IIS 使用此证书。打开管理命令提示符并导航到 IIS Express 文件夹,然后C:\Program Files (x86)\IIS Express运行:
IisExpressAdminCmd.exe setupSslUrl -url:https://YOUR.DOMAIN.NAME:PORTNUMBER -CertHash:THUMBPRINT
感谢:
https://improveandrepeat.com/2020/05/how-to-change-the-https-certificate-in-iis-express/
https://www.sonicwall.com/support/knowledge-base/how -can-i-import-certificates-into-the-ms-windows-local-machine-certificate-store/170504615105398/
/sf/answers/2726748321/
https://devblogs.microsoft.com/ aspnet/配置-https-in-asp-net-core-跨不同平台/
在计算机上安装证书,然后在cmd中运行:
"C:\Program Files (x86)\IIS Express\IisExpressAdminCmd.exe" setupSslUrl -url:https://my.domain.name:<port> -CertHash:<Certificate thumbprint>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5238 次 |
| 最近记录: |