用mkcert生成SSL,内网完美起跑https

3 篇文章 0 订阅
2 篇文章 0 订阅

一、下载安装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里转换格式,顺便把密码改了!

如果这篇文章对你有帮助,麻烦点下下面的【点赞】,哈哈~~~~完毕!!

  • 5
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

୧⍢⃝୨ LonelyCoder

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值