如果go版本在1.15以下,则使用如下证书生成方式
生成自签名证书
export NGROK_DOMAIN="wequee.com" openssl genrsa -out rootCA.key 2048 openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.pem openssl genrsa -out device.key 2048 openssl req -new -key device.key -subj "/CN=$NGROK_DOMAIN" -out device.csr openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000
替换证书(提示overwrite输入y)
cp rootCA.pem ../assets/client/tls/ngrokroot.crt cp device.crt ../assets/server/tls/snakeoil.crt cp device.key ../assets/server/tls/snakeoil.key
如果go版本在1.15以上
准备根证书临时ssl配置
vim ca.conf [ req ] default_bits = 4096 distinguished_name = req_distinguished_name
[ req_distinguished_name ] countryName = Country Name (2 letter code) countryName_default = CN stateOrProvinceName = State or Province Name (full name)