在Visual Studio中启用SSL - 不提示安装证书

时间:2016-08-28 09:20:17

标签: c# .net visual-studio ssl

我正在尝试按照此帖中的说明操作:http://www.codeproject.com/Tips/766918/Visual-Studio-Use-HTTPS-SSL-On-Web-Application-Pro。我没有收到消息提示"您是否要信任IIS SSL证书?"

证书存储中没有证书,如下所示:

enter image description here

我做错了什么?在Visual Studio中启动应用程序时,请查看我从IE和Firefox获得的警告:Enable SSL in Visual Studio

3 个答案:

答案 0 :(得分:0)

我通过以下步骤取得了一些进展:

    1) Click on the project name then F4 or View -> Properties Window
    2) Set SSL Enabled to: True
    3) Make a note of the SSL URL that is generated.  In my case it is: https://localhost:44334/
    4) Right click on the project name and select: Properties
    5) Set Project URL to the URL noted in step 3 i.e. https://localhost:44334/
    6) Open up a command prompt and run: "C:\Program Files (x86)\Windows Kits\8.1\bin\x64\makecert.exe"  -r -pe -n "CN=localhost" -b 01/01/2000 -e 01/01/2036 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12.  
    7) Go to mmc.exe and get the thumbprint of the certificate
    8) Run the following from a command line: netsh http add sslcert ipport=0.0.0.0:44334 appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash=2f11d025f2bc8802b45ceb7e03632eec333bc1ff.  2f11d025f2bc8802b45ceb7e03632eec333bc1ff is the thumbprint from step 8 and 44334 is the port from step 3.
    9) Run: netsh http add urlacl url=https://localhost:44334/ user=Everyone
    10) Launch the web app and I see this (
which looks a lot better):

enter image description here

11)转到MMC找到“个人”证书,然后将其移至:受信任的根证书颁发机构。

然后它有效。

上述所有步骤都可以在这篇文章中找到:http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx。我总结了我在以后的情况下(或其他任何人)想要引用它时所遵循的步骤 - 文章很长。请注意,在我的情况下:applicationhost.config是由Visual Studio自动编写的,而在链接中,编写者建议您手动写入以下文件:C:\ Users \ Ian \ Documents \ IISExpress \ config \ applicationhost.config。我的application.config文件位于.vs \ config文件夹中。

答案 1 :(得分:0)

配置IIS Express以使用SSL包括多个步骤,这在第一次使用时有点棘手。一个人必须做的最重要的部分如下:

  • 创建/获取/生成SSL证书。例如,可以使用MakeCert.exe生成自签名证书。查看%ProgramFiles(x86)%\Windows Kits\10\bin\x64%ProgramFiles(x86)%\Windows Kits\8.1\bin\x64实用程序MakeCert.exe实用程序。证书必须导入"受信任的根证书颁发机构"或"第三方根证书颁发机构"另外,在本地计算机(或本地用户)上使其受信任。
  • IIS Express使用操作系统的底层HTTP.SYS来处理所有HTTP / HTTPS请求。因此,必须对其进行配置,例如,使用netsh http add sslcert ...netsh http add urlacl ...或使用带有"%ProgramFiles%\IIS Express\IisExpressAdminCmd.exe"参数的setupFriendlyHostnameUrl实用程序。
  • 将Visual Studio项目配置为使用HTTPS进行调试,并使用HTTPS为IIS Express创建绑定。一般情况下,可以在没有Visual Studio的情况下运行IIS Express。然后,<binding>中应包含针对该网站的新%USERPROFILE%\Documents\IISExpress\config\applicationhost.co‌​‌​‌​nfig问题。如果仅在Visual Studio内部使用IIS Express,则Visual Studio将在$(solutionDir)\.vs\config\applicationhost.config文件中插入相应的绑定。

我建议您阅读并关注2011年Hanselman发布的the old article。今天的信息仍然有罪。

答案 2 :(得分:0)

只需修复您的 Visual Studio 即可重新生成 IIS Express 开发证书。

相关问题