如何在本地主机上使用 https / SSL?

发布于 2024-11-05 11:09:45 字数 141 浏览 0 评论 0原文

我想知道如何在本地主机上的 Web 应用程序上设置 SSL。

我没有这方面的背景,希望得到指导。我已经完成了我的 Web 应用程序的实现,我需要它在本地主机上或在服务器上托管它时使用 https。

有什么想法吗?

问候。

I would like to know how to setup SSL on my web application on the localhost.

I have no background in doing this, would appreaciate guidance. I already finished implementing my web application and i need it to use https on the localhost or while I host it on a server.

Any Ideas?

Regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鹿! 2024-11-12 11:09:46

如果您有 IIS Express(带有 Visual Studio):

要在 IIS Express 中启用 SSL,您只需设置“SSL
项目属性窗口中的“Enabled = true”。

请参阅此代码项目中的步骤和图片

IIS Express 将为您生成一个证书(系统将提示您输入证书等)。请注意,根据配置,站点可能仍会自动以 URL 而不是 SSL URL 启动。您可以看到 SSL URL - 记下端口号并将其替换到浏览器地址栏中,您应该能够进入并进行测试。

从那里,您可以右键单击您的项目,单击属性页,然后启动选项并分配启动 URL - 将新的 https 与新端口(通常为 44301 - 请注意与端口 443 的相似性),您的项目将从那时起正确启动在。

输入图像描述这里

If you have IIS Express (with Visual Studio):

To enable the SSL within IIS Express, you have to just set “SSL
Enabled = true” in the project properties window.

See the steps and pictures at this code project.

IIS Express will generate a certificate for you (you'll be prompted for it, etc.). Note that depending on configuration the site may still automatically start with the URL rather than the SSL URL. You can see the SSL URL - note the port number and replace it in your browser address bar, you should be able to get in and test.

From there you can right click on your project, click property pages, then start options and assign the start URL - put the new https with the new port (usually 44301 - notice the similarity to port 443) and your project will start correctly from then on.

enter image description here

爱本泡沫多脆弱 2024-11-12 11:09:46

创建自签名证书、导入并将其绑定到您的网站很容易。

1.) 创建自签名证书:

从提升的命令提示符运行以下 4 个命令,一次一个:

cd C:\Program Files (x86)\Windows Kits\8.1\bin\x64

makecert -r -n "CN=localhost" -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.3 -sv localhost.pvk localhost.cer

cert2spc localhost.cer localhost.spc

pvk2pfx -pvk localhost.pvk -spc localhost.spc -pfx localhost.pfx

2.) 将证书导入到受信任的根证书颁发机构存储:

start -->;运行--> mmc.exe -->证书插件 -->
“受信任的根证书颁发机构”-->证书

右键单击证书-->所有任务 -->进口
在 C:\Program Files (x86)\Windows Kits\8.1\bin\x64\ 中找到您的“localhost”证书

3.) 将证书绑定到网站:

开始 --> (IIS) 管理器 -->单击您的服务器 -->单击站点 -->单击您的顶级站点 -->绑定

添加或编辑 https 绑定并选择名为“localhost”的 SSL 证书。

4.) 将证书导入 Chrome:

Chrome 设置 -->管理证书 -->从 C:\certificates\ 文件夹导入 .pfx 证书

通过打开 Chrome 并导航到 https://localhost/ 测试证书

It is easy to create a self-signed certificate, import it, and bind it to your website.

1.) Create a self-signed certificate:

Run the following 4 commands, one at a time, from an elevated Command Prompt:

cd C:\Program Files (x86)\Windows Kits\8.1\bin\x64

makecert -r -n "CN=localhost" -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.3 -sv localhost.pvk localhost.cer

cert2spc localhost.cer localhost.spc

pvk2pfx -pvk localhost.pvk -spc localhost.spc -pfx localhost.pfx

2.) Import certificate to Trusted Root Certification Authorities store:

start --> run --> mmc.exe --> Certificates plugin -->
"Trusted Root Certification Authorities" --> Certificates

Right-click Certificates --> All Tasks --> Import
Find your "localhost" Certificate at C:\Program Files (x86)\Windows Kits\8.1\bin\x64\

3.) Bind certificate to website:

start --> (IIS) Manager --> Click on your Server --> Click on Sites --> Click on your top level site --> Bindings

Add or edit a binding for https and select the SSL certificate called "localhost".

4.) Import Certificate to Chrome:

Chrome Settings --> Manage Certificates --> Import .pfx certificate from C:\certificates\ folder

Test Certificate by opening Chrome and navigating to https://localhost/

似最初 2024-11-12 11:09:46

这个问题确实很老了,但是当我寻找最简单、最快的方法来做到这一点时,我遇到了这个页面。使用 Webpack 更简单:

安装 webpack-dev-server

npm i -g webpack-dev-server

使用 https 启动 webpack-dev-server

webpack-dev-server --https

This question is really old, but I came across this page when I was looking for the easiest and quickest way to do this. Using Webpack is much simpler:

install webpack-dev-server

npm i -g webpack-dev-server

start webpack-dev-server with https

webpack-dev-server --https
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文