自签 CA 证书

 阅读


小白壮壮又要水一篇博客啦

最近比较无聊,看到有大佬自签了 Surge/Quantumult 用于 HTTPS 解密的 CA 证书,可以自定义证书的名称有效期 (需求不大的话还是一键生成最方便)。就也想动手自己搞一个,就上网查了一下教程,先上一张效果图:

效果图


准备工具:

  • OpenSSL

  • Surge/Quantumult

开始折腾:

# 创建文件夹
mkdir zhuangzhuang

# 进入文件夹
cd zhuangzhuang
# 生成ca密钥
openssl genrsa -out ca.key 2048
# 生成CA证书
openssl req -x509 -new -nodes -key ca.key -subj "/C=CN/ST=Beijing/L=Beijing/O=ZHUANGZHUANG/OU=ZHUANGZHUANG/CN=ZHUANGZHUANG/emailAddress=mail@zhuangzhuang.ml" -days 36500 -out ca.crt
国家或地区 C CN
省/市/自治区 ST Beijing
所在地 L Beijing
组织 O ZHUANGZHUANG
组织单位 OU ZHUANGZHUANG
通用名称 CN ZHUANGZHUANG
电子邮件地址 emailAddress mail@zhuangzhuang.ml
有效期(天) -days 36500



其他注意事项:iOS 13 和 macOS 10.15 中的可信证书应满足的要求

如果需要更多自定义内容(比如颁发时间,我实在是搞不定了),建议使用在线工具生成,将生成的证书明文私钥明文分别保存在 ca.crt 、 ca.key 中,执行以下命令转换为 PKCS12 格式(也可以用在线工具转换)

一份在线工具签发证书的参考:


# 将CA转换成p12格式,并指定密码 (ZHUANGZHUANG)
openssl pkcs12 -export -clcerts -in ./ca.crt -inkey ca.key -out ca.p12 -password pass:ZHUANGZHUANG
# 将p12格式的证书Base64编码
base64 ca.p12

# Base64一行不能超过76字符,超过则添加回车换行符。如果因为换行的原因,不能安装证书,可以使用 -w 参数
base64 -w 0 ca.p12

打开 Surge/Quantumult,将密码和所得到的 BASE64 编码复制到相应位置,安装即可

[MITM]

# P12密码
ca-passphrase = ZHUANGZHUANG

# base64编码过的P12文件
ca-p12 = MIIKUQIBAzCCChcGCSqGSIb3DQEHAaCCCggEggoEMIIKADCCBLcGCSqGSIb3DQEHBqCCBKgwggSkAgEAMIIEnQ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GDewu0EiOauEIQCfHGXl1H4++JeTe5a9ZRF1Rrv7Vj8XP3z/XxcvWxaAg4U0j3DQ3jTvDhNIxJTAjBgkqhkiG9w0BCRUxFgQUOQe8L5GPZd+jbYh+0rsdC8/Q0z0wMTAhMAkGBSsOAwIaBQAEFOwZOmv+ydlxfxepg+0Z/tFYOg5oBAjZhjyf9SlFggICCAA=

注:此时得到的证书已经可以正常使用,若提示:未签名,先使用 Quantumult 安装证书

相关链接:Surge MitM 证书的创建和配置



 RSS-Telegram

 RSS订阅


 邮件订阅



 阅读时间

00:00:00


一言 获取中...