Visual Studio 2017 gives 'Adding the Certificate to The Trusted Root Certificates store failed with the following Errror'

落花浮王杯 提交于 2019-11-30 08:04:32
Will

Note: Adding the OP's solution from the question as an answer.

This is what worked for me. deleted all localhost certificates. ran repair IIS Express in Add/Remove Programs. Copy and pasted localhost certificate from Personal/Certificate to Trusted Root Certificates and it didn't complain anymore.

Repairing/reinstalling IIS Express does not appear to actually fix this issue (as of IIS Express 10), the real solution is to add the localhost certificate to Trusted Rood Certificates.

Full details for how to do this is covered by this blog post: https://blogs.iis.net/robert_mcmurray/how-to-trust-the-iis-express-self-signed-certificate

In summary,

  • Open the certificate manager via "manage computer certificates" in control panel or by running certlm in a cmd prompt
  • Under Personal>Certificates export the localhost cert and save it to disk
    • don't export the private key! Just export the public key.
  • Under Trusted Root Certification Authorities, right click on Certificates and import the cert you just exported

It worked to me just running CMD > certlm and deleting the localhost certificate inside the personal folder.

After having struggled with this issue now for a week (using Win 10 and Visual Studio 2019 Community Edition Version 16.1.1) and trying various solutions I found out the following:

  • by default the localhost certificate for IISExpress 10 gets installed in: Certificates (Local Computer) -> Personal

  • Repairing IISExpress 10 (Programs -> Programs and Features) will create a new localhost certificate also in: Certificates (Local Computer) -> Personal

  • Then export that certificate by saving it to a file using:

Then import that certificate into: Certificates (Local Computer) -> Trusted Root Certification Authorities

  • then as user2988031 pointed out: delete the certificate from Certificates (Local Computer) -> Personal

I also tried to use "dotnet dev-crts https --trust" but that did not work for me and always produced the following error:

So to wrap it up: make shure there is only 1 localhost certificate which is in Certificates (Local Computer) -> Trusted Root Certification Authorities

Update: I just realized that after modifying the web application a few times a different error manifested and I had to go through the whole process again in order to get it to work!

My error was actually "asp.net developer certificate is not installed" but I think the solution below would still work in this case. Execute the following commands in command prompt.

dotnet dev-certs https --trust --check
echo Trust check: %errorlevel%
dotnet dev-certs https --trust -ep "%APPDATA%\ASP.NET\https\TestCert.pfx" -p TestPassword
echo Trust/Export: %errorlevel%

Reference: https://github.com/Microsoft/DockerTools/issues/147#issuecomment-420433974

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!