WSL安装mkcert

wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64
mv mkcert-v1.4.3-linux-amd64 mkcert
sudo install mkcert /usr/local/bin

Windows 安装 mkcert

使用 Chocolatey 或者 Scoop 

Scoop 安装,在powershell运行

set-executionpolicy remotesigned -scope currentuser
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
#测试
scoop help
#安装 mkcert
#bucket add 失败请使用代理 scoop config proxy 127.0.0.1:7911 移除代理 scoop config rm proxy
scoop bucket add extras
scoop install mkcert

配置证书

-powershell
mkcert -install

-wsl
mkcert -install
# 复制windows下的根证书到 wsl
# windows默认位置 C:\Users\Username\AppData\Local\mkcert
# wsl 默认位置 /home/username/.local/share/mkcert
cp -r /mnt/c/Users/Username/AppData/Local/mkcert/* /home/username/.local/share/mkcert/

cd /home/username/.local/share/mkcert/
mkcert localhost example.test ::1

#修改nginx/apache 配置
ssl_certificate     /home/username/.local/share/mkcert/localhost+2.pem;
ssl_certificate_key /home/username/.local/share/mkcert/localhost+2-key.pem;

# 重启nginx/apache