本地 UWP 客户端到本地 asp.net core api web 服务器 - 证书颁发机构无效或不正确

DFB*_*rry 1 c# asp.net certificate client-certificates uwp

我正在接管别人的项目并试图让前端(UWP)与后端(asp.net core 2.x api)对话。

它们独立工作,后端在调试时打开浏览器到正确的路由https://localhost:44319/api/status。当我尝试将前端连接到后端时,我得到The certificate authority is invalid or incorrect

该代码使用 HttpClient。

HttpClient client = new HttpClient(new 
HttpClientHandler() { UseDefaultCredentials = true });
var uri = new Uri(string.Format(accountListServiceUri, string.Empty));
var response = await client.GetAsync(uri);
Run Code Online (Sandbox Code Playgroud)

我正在通过 IISExpress 运行后端,并使用以下 powershell 脚本来获取 IIS Express 开发证书的缩略图。

View certificate Copy Set-Location Cert:\LocalMachine\My Get-ChildItem | Format-Table Subject, FriendlyName, Thumbprint
Run Code Online (Sandbox Code Playgroud)

我使用缩略图制作了一个 pfx 文件。

Get-ChildItem -Path cert:\localMachine\my\<THUMBNAIL> | Export-PfxCertificate -FilePath C:\<PROJECTNAME>.pfx -Password $mypwd
Run Code Online (Sandbox Code Playgroud)

然后我根据不同的 SO 答案将 pfx 导入受信任的根证书颁发机构和受信任的人。

认为服务器设置正确,但客户端没有。我想在不输入 #debug 代码的情况下解决这个问题,因为它不会通过安全检查。

感谢您的任何帮助。

DFB*_*rry 7

修复是配置 UWP 包清单的功能,包括Shared User Certificates在此处输入图片说明