程序开发时,避免不了使用https加密通信,可以通过 openssl
工具来生成 ssl
证书,对于不懂的开发来说,openssl
工具是太难使用。有没有一个好用又简单的工具,可以试一试这个用Go语言写的命令行工具:mkcert
,非常简单易用。
mkcert
是一个使用go语言编写的生成本地自签证书的小工具,具有跨平台,使用简单,支持多域名,自动信任CA等一系列方便的特性,可供本地开发时快速创建 https
环境使用。
mkcert
是制作本地信任的开发证书简单工具。它不需要任何配置。
$ mkcert -install
Created a new local CA at "/Users/filippo/Library/Application Support/mkcert" ?
The local CA is now installed in the system trust store! ⚡️
The local CA is now installed in the Firefox trust store (requires browser restart)! ?
$ mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1
Using the local CA at "/Users/filippo/Library/Application Support/mkcert" ✨
Created a new certificate valid for the following names ?
- "example.com"
- "*.example.com"
- "example.test"
- "localhost"
- "127.0.0.1"
- "::1"
# 证书文件输出在当前目录下
The certificate is at "./example.com+5.pem" and the key at "./example.com+5-key.pem" ✅
$ brew install mkcert
$ brew install nss # Firefox 浏览器支持
首先安装 certutil
$ sudo apt install libnss3-tools
或者
$ sudo yum install nss-tools
或者
$ sudo pacman -S nss
或者
$ sudo zypper install mozilla-nss-tools
然后可以使用 Linuxbrew 进行安装
$ brew install mkcert
或从源代码构建(需要Go 1.13+)
$ git clone https://github.com/FiloSottile/mkcert
$ cd mkcert
$ go build -ldflags "-X main.Version=$(git describe --tags)"
$ choco install mkcert
$ brew install nginx
ssl_certificate /usr/local/etc/nginx/ssl/example.com+5.pem;
ssl_certificate_key /usr/local/etc/nginx/ssl/example.com+5-key.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES2
$ nginx -t && nginx -s reload
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有