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

2022-12-05 12:49:10 +08:00
 eBMm8zIi0Zq3
  1. 证书有效时间长,少折腾。
  2. 免费
  3. 证书在全平台都可以安装,尤其是 iOS 设备。
  4. 由于国内云的限制,所有带域名的,都无法逃过被拦截,所以可以用 IP+端口+证书的方式访问。
  5. 服务端种类比较多,一张证书能长期解决。

效果图:


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

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

[ 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            = me@home.com

# 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

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

cp *.crt /usr/local/share/ca-certificates/

update-ca-certificates
ssl_certificate /home/ssl/xxx/ca.crt;

ssl_certificate_key /home/ssl/xxx/ca.key;

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

631 次点击
所在节点   科技
2 条回复
me221
2022-12-05 13:22:35 +08:00
tms
2022-12-05 15:15:28 +08:00
一直用 step-ca

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/900184

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX