一、下載安裝mkcert,截止至2020-5-9,最新版本爲1.4.1
1、windows系統:直接下載解壓即可。
下載:https://download.csdn.net/download/alinathz/12402537
2、linux系統:
在CentOS和Fedora中安裝mkcert類似於Ubuntu/Debian安裝,只需要先安裝nss-tools工具:
sudo yum install nss-tools
安裝完成後,下載二進制包,截止至2020-5-9,最新版本爲1.4.1:
wget -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-linux-amd64
下載文件後,使文件可執行並將二進制文件放在/usr/loa/bin下:
chmod +x mkcert
sudo mv mkcert /usr/local/bin
二、mkcert的使用方法
1、安裝CA根證書到本地
mkcert -install
2、生成證書
mkcert 127.0.0.1 localhost //後面還可以繼續空格添加其他域名或IP地址,默認是pem格式
mkcert -pkcs12 192.168.10.123 //生成p12格式的正式iis可以用,默認密碼爲:“changeit”
mkcert -client 192.168.10.123 //客戶端證書,默認是pem格式
mkcert -pkcs12 -client 192.168.10.123 //生成p12格式客戶端證書,win用戶可以直接導入,默認密碼爲:“changeit”
更多的使用方法,可以用以下命令查看
mkcert -help
Usage of mkcert:
$ 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).
Advanced options:
-cert-file FILE, -key-file FILE, -p12-file FILE
Customize the output paths.
-client
Generate a certificate for client authentication.
-ecdsa
Generate a certificate with an ECDSA key.
-pkcs12
Generate a ".p12" PKCS #12 file, also know as a ".pfx" file,
containing certificate and key for legacy applications.
-csr CSR
Generate a certificate based on the supplied CSR. Conflicts with
all other flags and arguments except -install and -cert-file.
-CAROOT
Print the CA certificate and key storage location.
$CAROOT (environment variable)
Set the CA certificate and key storage location. (This allows
maintaining multiple local CAs in parallel.)
$TRUST_STORES (environment variable)
A comma-separated list of trust stores to install the local
root CA into. Options are: "system", "java" and "nss" (includes
Firefox). Autodetected by default.
三、其他
mkcert不一定要在服務器上安裝生成,只要把生成的證書導入或部署到web服務器上就可以了,然後把生成出來的client證書安裝到各客戶端電腦上即可。
以IIS爲例:將生成出來的192.168.10.123.p12文件,copy到服務器上,打開IIS管理器,在【服務器證書】裏,直接導入即可。再把192.168.10.123-client.p12下發給個客戶端電腦,直接雙擊安裝即可。
注意,p12格式證書的默認密碼爲:changeit
如果需要更改這個默認密碼,我能想到的就是生成pem格式,然後在https://www.chinassl.net/ssltools/convert-ssl.html裏轉換格式,順便把密碼改了!
如果這篇文章對你有幫助,麻煩點下下面的【點贊】,哈哈~~~~完畢!!