如何为 localhost 创建自签名证书? [英] How can I create a self-signed cert for localhost?

查看:30
本文介绍了如何为 localhost 创建自签名证书?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了

通过启动mmc.exe来解决这个问题.

然后转到:

文件 -> 添加或删除管理单元 -> 证书 -> 添加 -> 计算机帐户 -> 本地计算机.点击完成.

展开 Personal 文件夹,您将看到您的 localhost 证书:

将证书复制到 Trusted Root Certification Authorities - Certificates 文件夹中.

最后一步是打开 Internet Information Services (IIS) Manager 或简单地打开 inetmgr.exe.从那里转到您的站点,选择 Bindings...Add...Edit....设置 https 并从下拉列表中选择您的证书.

您的证书现在受信任:

I've gone through the steps detailed in How do you use https / SSL on localhost? but this sets up a self-signed cert for my machine name, and when browsing it via https://localhost I receive the IE warning.

Is there a way to create a self-signed cert for "localhost" to avoid this warning?

解决方案

Since this question is tagged with IIS and I can't find a good answer on how to get a trusted certificate I will give my 2 cents about it:

First use the command from @AuriRahimzadeh in PowerShell as administrator:

New-SelfSignedCertificate -DnsName "localhost" -CertStoreLocation "cert:LocalMachineMy"

This is good but the certificate is not trusted and will result in the following error. It is because it is not installed in Trusted Root Certification Authorities.

Solve this by starting mmc.exe.

Then go to:

File -> Add or Remove Snap-ins -> Certificates -> Add -> Computer account -> Local computer. Click Finish.

Expand the Personal folder and you will see your localhost certificate:

Copy the certificate into Trusted Root Certification Authorities - Certificates folder.

The final step is to open Internet Information Services (IIS) Manager or simply inetmgr.exe. From there go to your site, select Bindings... and Add... or Edit.... Set https and select your certificate from the drop down.

Your certificate is now trusted:

这篇关于如何为 localhost 创建自签名证书?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆