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

随笔1天前发布 王康军
5 0 0

合集 – 笔记(19)
1.BootstrapBlazor 模板适配移动设备使用笔记02-08
2.使用 Kestrel 自托管https 并作为 Windows 服务启动 Blazor 提示: 无法配置 HTTPS 端点。未指定服务器证书,找不到默认的开发者证书解决方法02-083.宝塔部署自动续签SSL证书跟 oauth get OpenIdConnect WellknownConfiguration 冲突解决方法01-114.在 Blazor WASM 中手撸一个.NET MD5类2023-11-255.Windwos Server 2012 自带的端口转发工具的命令2023-12-146.C# 11 原始字符串文本2023-09-027.完整记录一次 Microsoft Teams 登录过程2023-02-088.调试了一个早上, 定位了一个chrome的新问题, 新版chrome 不能有效的追踪客户来源Referer了2020-10-159.使用 Visual Studio 2022 的 .http 文件方式调试 API03-0810.在 VS 中快速定位打开的文件04-0911.Blazor/Hybird 触屏下单程序调优笔记05-0612.Ubuntu 更新到 22.04.4 LTS 记录器 syslog 出错06-0813.[解决] chrome/edge浏览器打开F12开发者模式,点击应用标签崩溃06-2114.云主机 Ubuntu 22.04.4 LTS 更新后每隔20分钟服务器就停止响应06-2115.mui里点击input框是为什么会返回顶部06-2216..net6+ 在单文件应用程序中获取程序集位置07-0217.ubuntu apt update 提示 The repository ‘http://xxx Release‘ does not have a Release file07-0418.邮件服务器迁移到 amazon aws 云主机07-0619.转发wsa和安卓模拟器网络08-07

收起

原文链接 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: emp。(您可以使用任何其他路径,只要您的网络应用程序可以读取即可)

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

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

  "Kestrel": {
    "EndPoints": {
      "Https": {
        "Url": "https://localhost:5000",
        "Certificate": {
          "Path": "C:\temp\cert.pfx",
          "Password": "MyPassword",
          "AllowInvalid": "true"
        }
      }
    }
  }
© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...