分享下自签名全平台通用的 IP/域名证书的方法 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
eBMm8zIi0Zq3
V2EX    科技

分享下自签名全平台通用的 IP/域名证书的方法

  •  
  •   eBMm8zIi0Zq3 2022-12-05 12:49:10 +08:00 1336 次点击
    这是一个创建于 1090 天前的主题,其中的信息可能已经有所发展或是发生改变。
    • 我的初始要求:
    1. 证书有效时间长,少折腾。
    2. 免费
    3. 证书在全平台都可以安装,尤其是 iOS 设备。
    4. 由于国内云的限制,所有带域名的,都无法逃过被拦截,所以可以用 IP+端口+证书的方式访问。
    5. 服务端种类比较,一张证书能长期解决。

    效果图:
    iOS-1 iOS-2 Android-1 Android-2

    基于以上要求,我试了很多方法,one-self-signed-cert-to-rule-them-all-chrome-android-and-ios可以签出全平台通用的域名证书

    以下部分是关于IP 证书自签的:

    • 首先创建个配置文件 openssl.cnf
    [ req ] default_bits = 2048 default_keyfile = ca.key default_md = sha256 default_days = 825 encrypt_key = no distinguished_name = subject req_extensiOns= req_ext x509_extensiOns= x509_ext string_mask = utf8only prompt = no [ subject ] countryName = US stateOrProvinceName = Oklahoma localityName = Stillwater organizatiOnName= My Company OU = Engineering commOnName= 你的 IP emailAddress = [email protected] # Section x509_ext is used when generating a self-signed certificate. I.e., openssl req -x509 ... [ x509_ext ] subjectKeyIdentifier = hash authorityKeyIdentifier = keyid:always,issuer basicCOnstraints= critical, CA:TRUE keyUsage = critical, digitalSignature, keyEncipherment, cRLSign, keyCertSign subjectAltName = IP:你的 IP extendedKeyUsage = serverAuth extendedKeyUsage = TLS Web Server Authentication [ req_ext ] subjectKeyIdentifier = hash basicCOnstraints= CA:FALSE keyUsage = digitalSignature, keyEncipherment subjectAltName = IP:你的 IP nsComment = "OpenSSL Generated Certificate" [alt_names] IP.1=你的 IP 
    • 然后用命令生成就行:
    openssl req -config openssl.cnf -new -x509 -days 825 -out ca.crt openssl x509 -in ca.crt -text -noout 
    • 关于导入还是挺方便的,网上的普通教程就行。导入.CRT 就行。

    在 Debian / Ubuntu / Alpine 系统中信任证书:

    cp *.crt /usr/local/share/ca-certificates/ update-ca-certificates 
    • 关于 nginx 配置
    ssl_certificate /home/ssl/xxx/ca.crt; ssl_certificate_key /home/ssl/xxx/ca.key; 
    • 关于安全 我在 V2EX 搜索过,关于安全方面,大家说安装证书到设备后只要私钥不泄漏,加密还是能保证的。

    首次在此发言,若有安全隐患或者另有妙招还请多多指教。

    2 条回复    2022-12-05 15:15:28 +08:00
    me221
        1
    me221  
       2022-12-05 13:22:35 +08:00
    tms
        2
    tms  
       2022-12-05 15:15:28 +08:00
    一直用 step-ca
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2681 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 23ms UTC 13:19 PVG 21:19 LAX 05:19 JFK 08:19
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86