使用 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"
}
}
}
}
标签:HTTPS,certificate,证书,Windows,cert,Kestrel,未指定,https
From: https://www.cnblogs.com/densen2014/p/18011622