使用 Kestrel 自托管https 并作为 Windows 服务启动 Blazor 提示: 无法配置 HTTPS 端点。未指定服务器证书,找不到默认的开发者证书解决方法

12 篇文章 0 订阅
5 篇文章 0 订阅

原文链接 https://stackoverflow.com/questions/53300480/unable-to-configure-https-endpoint-no-server-certificate-was-specified-and-the/71026252#71026252

使用 Kestrel 自托管并作为 Windows 服务启动 Blazor 提示

Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
   at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)

搜遍了互联网终于找到一个可行办法

我使用 Powershell 和此命令创建了一个自签名证书。[我从互联网上的某个地方复制了这个 PowerShell 片段。不记得来源了。] 首先,请确保您的计算机上有一个可写位置:C:\temp\。(您可以使用任何其他路径,只要您的网络应用程序可以读取即可)

 $cert = New-SelfSignedCertificate -DnsName mydemowebapp.net -CertStoreLocation cert:\LocalMachine\My
  $pwd = ConvertTo-SecureString -String "MyPassword" -Force -AsPlainText
  Export-PfxCertificate -Cert $cert -FilePath C:\temp\cert.pfx -Password $pwd

然后,在我的 appsertings.Development.json 中,我添加了此条目。

  "Kestrel": {
    "EndPoints": {
      "Https": {
        "Url": "https://localhost:5000",
        "Certificate": {
          "Path": "C:\\temp\\cert.pfx",
          "Password": "MyPassword",
          "AllowInvalid": "true"
        }
      }
    }
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Densen2014

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值