openssl 签发中间证书

前置条件

签发中间证书

  • 创建配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cat << 'EOF' > intermediate_ca_v3.ext
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
basicConstraints = critical, CA:true, pathlen:0
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
authorityInfoAccess = @Info_access
crlDistributionPoints = @crl_section
certificatePolicies = @polsect

# .0 的这种格式,可以写多个,如URI.0、URI.1、URI.2
[ Info_access ]
OCSP;URI.0 = http://ocsp.privatesign.local.com
caIssuers;URI.0 = http://secure.privatesign.local.com/cacert/PrivateSignRootCA.crt

[ crl_section ]
URI.0 = http://crl.privatesign.local.com/crl/root.crl

[ polsect ]
policyIdentifier = X509v3 Any Policy
CPS.1 = http://www.privatesign.local.com

EOF
  • 创建私钥

    1
    (umask 077; openssl genrsa -out intermediate_ca.key 2048)
  • 创建证书签署请求

    1
    2
    3
    4
    5
    openssl req -new \
    -key intermediate_ca.key \
    -out intermediate_ca.csr \
    -subj "/C=CN/O=SRE/CN=PrivateSign RSA SSL CA 2019"
    # openssl req -noout -text -in intermediate_ca.csr
  • 使用CA签名并生成证书

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    openssl rand -hex 14 > serial.srl
    openssl x509 -req -sha512 \
    -days 3650 \
    -CAserial serial.srl \
    -CAcreateserial \
    -CA ca.crt \
    -CAkey ca.key \
    -in intermediate_ca.csr \
    -extfile intermediate_ca_v3.ext \
    -out intermediate_ca.crt
  • 查看和校验证书

    1
    2
    openssl x509 -noout -text -in intermediate_ca.crt
    openssl verify -CAfile ca.crt intermediate_ca.crt
  • 创建证书链

    1
    2
    3
    4
    5
    # 创建中间ca的证书链,中间证书在上面,根证书在下面
    cat intermediate_ca.crt ca.crt > intermediate_ca_chain.crt

    # 测试证书的签发状态
    openssl verify -CAfile ca.crt intermediate_ca_chain.crt

完整证书链结构

1
2
3
4
5
6
7
8
9
-----BEGIN CERTIFICATE-----
用户证书
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
中间证书
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
根证书
-----END CERTIFICATE-----

签发服务端证书

点击跳转到签发服务端证书
打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2018-2024 Outsrkem
  • 访问人数: | 浏览次数:

      请我喝杯咖啡吧~

      支付宝
      微信