Loading... # 引言 我们通常建站测试的时候,都是直接127.0.0.1这样访问的,也就是使用的http协议,那么如果需要HTTPS协议访问本地站点呢? # 准备工作 1. [mkcert](https://github.com/FiloSottile/mkcert/releases/) 2. Web浏览器一个(Chrome) 3. Windows系统 # 命令介绍 ``` $ mkcert -install Install the local CA in the system trust store. $ mkcert example.org Generate "example.org.pem" and "example.org-key.pem". $ mkcert example.com myapp.dev localhost 127.0.0.1 ::1 Generate "example.com+4.pem" and "example.com+4-key.pem". $ mkcert "*.example.it" Generate "_wildcard.example.it.pem" and "_wildcard.example.it-key.pem". $ mkcert -uninstall Uninstall the local CA (but do not delete it). ``` # 步骤 执行 `mkcert -install` 安装证书 执行 `mkcert localhost 127.0.0.1 ::1` 生成证书文件 > 会生成两个文件localhost.pem localhost-key.pem > 我这儿重命名了一下,改成了localhost.crt 和 localhost.key 配置WEB服务器应用,如nginx  打开`certmgr.msc`导入刚刚生成的证书   重启一下浏览器,就可以看到效果了。   实测:chrome edge可以,但是firefox仍然存在告警(但是可以例外) © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏