下载

1
https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-windows-amd64.exe

安装CA根证书到本地

1
mkcert -install

生成证书

192.168.60.xx 服务ip 地址

1
mkcert-v1.4.4-windows-amd64.exe  192.168.60.162

会生成

1
2
192.168.60.162.pem
192.168.60.162-key.pem

查看根目录

1
mkcert-v1.4.4-windows-amd64.exe   -CAROOT

输出:

1
C:\Users\shuzhuo\AppData\Local\mkcert

进入目录会有两个文件

1
2
rootCA.pem
rootCA-key.pem

把 rootCA.pem根证书,修改扩展名改为rootCA.pem.cer,拷贝到需要访问https的windows电脑上

客户端双击安装即可

image-20230701122710148

image-20230701122750716

image-20230701122854334

image-20230701122940280

image-20230701123002209

image-20230701123022376

image-20230701123035424

例子:

1
2
3
4
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不一定要在服务器上安装生成,只要把生成的证书导入或部署到web服务器上就可以了,然后把生成出来的client证书安装到各客户端电脑上即可。

注意,p12格式证书的默认密码为:changeit

如果需要更改这个默认密码,我能想到的就是生成pem格式,然后在https://www.chinassl.net/ssltools/convert-ssl.html里转换格式,顺便把密码改了!

nginx 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
server {
listen 80;
server_name _;
return 301 https://$http_host$request_uri;
}

server {
listen 443 ssl;
server_name _;
charset utf-8;
root /data/wwwroot/password-evaluation-html;
ssl_certificate cert/192.168.60.162.pem;
ssl_certificate_key cert/192.168.60.162-key.pem;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
ssl_prefer_server_ciphers on;
error_page 497 https://$host:$server_port$uri$is_args$args;

client_max_body_size 2048m;

location / {
try_files $uri $uri/ @router;
index index.html index.htm;
}

location @router {
rewrite ^.*$ /index.html last;
}

location /mp/ {
proxy_pass https://192.168.60.160:8060/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}

Firefox

方法1:

1
2
about:config
security.enterprise_roots.enabled =true

方法2

双击安装默认的路径,把服务器例外的证书删除(必须要删除),再把切换 证书颁发机构tab ,重新导入证书即可

image-20230701171931937

image-20230701172024140

image-20230701171103963