-
Notifications
You must be signed in to change notification settings - Fork 183
使用BabaSSL签发SM2证书
Paul Yang edited this page Jun 7, 2021
·
1 revision
openssl ecparam -genkey -name SM2 -out sm2.key
openssl req -new -key sm2.key -out sm2.csr -sm3 -sigopt "sm2_id:1234567812345678"
openssl x509 -req -in sm2.csr -signkey sm2.key -out sm2.crt -sm3 -sm2-id 1234567812345678 -sigopt "sm2_id:1234567812345678"
以构建一个三级证书链为例,见BabaSSL/test_certs/sm2-cert-sign
,通过gen-sm2-cert-sign-dir.sh
生成签发证书的文件目录
- 编写
openssl.cnf
,见BabaSSL/test_certs/sm2-cert-sign/ca
目录下 - 通过步骤一,二生成根证书的私钥和csr
- 生成自签名根证书:
openssl ca -selfsign -config openssl.cnf -in csr/sm2-root.csr -extensions v3_ca -days 3650 -out sm2-root.crt
- 通过步骤一,二生成中间证书的私钥和
sm2-intermediate-ca.csr
- 生成中间ca
openssl ca -config openssl.cnf -extensions v3_intermediate_ca -days 3650 -in csr/sm2-intermediate-ca.csr -out sm2-intermediate-ca.crt -sigopt "sm2_id:1234567812345678" -sm2-id "1234567812345678" -md sm3
- 为中间ca编写
openssl_middleca.cnf
,见BabaSSL/test_certs/sm2-cert
目录下 - 通过步骤一,二生成叶子证书的私钥和
sm2-leaf.csr
- 生成叶子证书
openssl ca -config openssl_middleca.cnf -extensions server_cert -days 3650 -in csr/sm2-leaf.csr -out sm2-leaf.crt -sigopt "sm2_id:1234567812345678" -sm2-id "1234567812345678" -md sm3
吊销叶子证书
openssl ca -revoke certs/sm2-leaf.crt -cert certs/sm2-root.crt -key private/sm2-root.key -config openssl.cnf -md sm3 -sm2-id 1234567812345678 -sigopt "sm2_id:1234567812345678"
生成crl
openssl ca -gencrl -out sm2-leaf.crl -cert certs/sm2-root.crt -key private/sm2-root.key -config openssl.cnf
BabaSSL Project Team
Don't know what to add...