目标是我可以从VS2022(Kestrel)启动我的.Net Blazor Server应用程序,使用我的开发人员机器的IP地址(所以不是127.0.0.1或localhost),而是我的有效机器IP(172.23.110.47),并且我可以在这样做的同时拥有正确的HTTPS连接。我在PowerShell中运行了以下代码
PS C:\windows\system32> New-SelfSignedCertificate -Subject "localhost" -TextExtension @("2.5.29.17={text}DNS=localhost&IPAddress=127.0.0.1&IPAddress=::1&IPAddress=172.23.110.47")
PSParentPath: Microsoft.PowerShell.Security\Certificate::LocalMachine\MY
Thumbprint Subject
---------- -------
53E7417A264B229B4F52638B15433F7C09476224 CN=localhost
PS C:\windows\system32> $mypwd = ConvertTo-SecureString -String "ControlTech" -Force -AsPlainText
PS C:\windows\system32> Get-ChildItem -Path cert:\localMachine\my\53E7417A264B229B4F52638B15433F7C09476224 | Export-PfxCertificate -FilePath C:\temp\MyJpfCertificate.pfx -Password $mypwd
Verzeichnis: C:\temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 21.03.2023 09:05 2685 MyJpfCertificate.pfx
PS C:\windows\system32> dotnet dev-certs https --clean --import C:\Temp\MyJpfCertificate.pfx -p ControlTech
Cleaning HTTPS development certificates from the machine. A prompt might get displayed to confirm the removal of some of the certificates.
HTTPS development certificates successfully removed from the machine.
The certificate at 'C:\Temp\MyJpfCertificate.pfx' is not a valid ASP.NET Core HTTPS development certificate.
C:\Temp\MyJpfCertificate.pfx中的证书不是有效的ASP.NET Core HTTPS开发证书。我错过了什么?
1条答案
按热度按时间s4n0splo1#
你可以试试:
证书将具有EKU扩展名和服务器身份验证OID,并且在DnsNameList中不具有“localhost”。