在VS2015上将ssl与asp.net mvc 5与localhost一起使用 [英] Using ssl with localhost with asp.net mvc 5 on VS2015
问题描述
我正尝试使用SSL和IIS Express在本地测试我的网站.它设置了以下属性:
-
已启用SSL
设置为'true' 设置 -
SSL URL
在Google Chrome浏览器中:
我读了几篇文章,包括一些有关SO的文章,但无济于事.我尝试了以下方法:
- 我已经删除了
IIS Express开发证书
- 我已经通过
Control Panel
修复了 - 我已经删除了我手动创建的
localhost
证书. - 我已将
<绑定协议="https" bindingInformation ="*:44354:localhost"/>
添加到applicationhost.config - 我已经停止并重新启动了
IIS Express
. - 有人建议将端口更改为443,但我的
SSL URL
在.NET IDE
中是只读的. - 我读过的一些文章:
-
- 一旦导入,我就回到Asp.Net MVC 5项目,重新编译并运行它.当我运行它时,系统提示我以下内容:
这是我知道自己处在正确的轨道上的时候,因为这是我第一次看到此提示!单击是,现在出现此提示:
然后在此提示上也单击是".然后,您的项目将启动相关的浏览器.
转到您的.net项目中定义的https地址(在我的实例中为
https://localhost:44354/
),现在您将看到地址栏中显示的挂锁指示您这是一个安全的网站:大多数答案已经可以在SO上提供的不同答案中找到,但是遗漏或遗漏的要点是必须导出
IIS Express Development
证书,删除所有localhost条目((我已经完成),然后重新导入此证书.完成后,.NET将检测到更改,并相应地提示您.无论如何,我希望这对其他人有帮助.
I'm trying to test my website locally using SSL with IIS Express. It has the following properties set:
SSL Enabled
set to 'true'SSL URL
is set https://localhost:44354/
But whenever I open the https address, I get the following error:
In "Microsoft Edge":
In Google Chrome:
I've read article after articles, including some on SO but to no avail. I've tried the following:
- I've deleted my
IIS Express Development Certificate
- I've repaired
IIS Express 10
via theControl Panel
- I've removed the
localhost
certificate I had created manually. - I've added
<binding protocol="https" bindingInformation="*:44354:localhost" />
to thebindings
section the applicationhost.config - I've stopped and restarted
IIS Express
. - Some suggest to change the port to 443 but my
SSL URL
is read-only in.NET IDE
. - Some articles I've read:
Any help would be greatly appreciated.
Thanks.
解决方案I finally figured it out by following this article How to trust the IIS Express Self-Signed Certificate but a few additional steps:
Export
IIS Express Development
certificate to a local from. This certificate can be found in theServer Certificates
section inIIS 10.0
.Open the
Certificate console
by callingmmc.exe certmgr.msc
from File|Run.Delete all instances of localhost under the
Trusted Root Certification Authorities|Certificates
.Import the newly created certificate. You will get prompted with the following:
- Once imported, I went back to Asp.Net MVC 5 project, recompile it and ran it. When I ran it, I got prompted with the following:
This is when I knew I was on the right track as this was the first time I had ever seen this prompt! Click Yes, and now this prompt appears:
And click Yes on this prompt as well. Your project will then launch the relevant browser.
Go to the https address defined in your .net project, in my instance,
https://localhost:44354/
, and you will now see the padlock displayed in the address bar to indicate that it is a secure site:Most of these answers were already available in different answers provided on SO but the points that were missing or that I missed were that I had to export my
IIS Express Development
certificate, delete all localhost entries (which I had done) and then re-import this certificate. Once done, .NET detects the change and you get prompted accordingly.Anyway, I hope this will help others.
这篇关于在VS2015上将ssl与asp.net mvc 5与localhost一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-
IIS Express 10
- 我已经删除了