标签:tab param cert subject csr gnu 依赖 书签 实验环境
Linux ubuntu/Centos 64 x86_64 x86_64 x86_64 GNU/Linux
$ unzip GmSSL-master.zip $ cd GmSSL-master $ ./config no-saf no-sdf no-skf no-sof no-zuc no-shared #不去编译动态库,编译出来的gmssl不再依赖libssl.so $ make $ sudo make install
$ vi /usr/local/sslopenssl.cnf
[ ca ] default_ca = CA_default # The default ca section [ CA_default ] #dir = ./demoCA # Where everything is kept dir = /home/myapp/demoCA #此处修改
$ mkdir -p /home/myapp/demoCA $ cd /home/myapp/demoCA
在此路径下要创建好/usr/local/ssl/openssl.cnf中需要的certs, crl ,new_certs_dir和private_key的子目录,默认是newcerts和private
$ mkdir certs crl newcerts private
touch index.txt
echo "01" > serial
$ gmssl ecparam -genkey -name sm2p256v1 -text -out Root.key -config /usr/local/ssl/openssl.cnf
$ gmssl req -new -key Root.key -out Root.req -subj /C=CN/ST=Guang\ Zhou/L=GZ/O=Root/OU=Root\ Sign/CN=RootCA/emailAddress=Root@gmail.com -config /usr/local/ssl/openssl.cnf
$ gmssl x509 -req -days 3650 -sm3 -in Root.req -signkey Root.key -out RootCA.crt $ cp RootCA.crt demoCA/ $ cp Root.key demoCA/private/
类似于 apache/ssl/ca.crt和apache/ssl/ca.key
$ gmssl ecparam -genkey -name sm2p256v1 -text -out Medium.key -config /usr/local/ssl/openssl.cnf
$ gmssl req -new -key Medium.key -out Medium.req -subj /C=CN/ST=Guang\ Zhou/L=GZ/O=Medium/OU=Medium\ Sign/CN=MediumCA/emailAddress=Medium@gmail.com -config /usr/local/ssl/openssl.cnf
$ gmssl x509 -req -sm3 -days 3650 -CA RootCA.crt -CAkey demoCA/private/Root.key -CAcreateserial -in Medium.req -out MediumCA.crt
$ gmssl verify -CAfile RootCA.crt MediumCA.crt
$ cp MediumCA.crt demoCA/ $ cp Medium.key demoCA/private/
$ gmssl pkcs12 -export -inkey Medium.key -in MediumCA.crt -out test.pfx -passin pass:xxx -passout pass:xxx
PKCS转换为PEM gmssl pkcs12 -in test.pfx -out cert.pem -nodes 转换后可查看证书信息 打印出证书的内容: gmssl x509 -in cert.pem -noout -text 打印出证书的系列号 gmssl x509 -in cert.pem -noout -s erial 打印出证书的拥有者名字 gmssl x509 -in cert.pem -noout -subject 打印出证书的MD5特征参数 gmssl x509 -in cert.pem -noout -fingerprint
$ gmssl ecparam -genkey -name sm2p256v1 -text -out Server.key -config /usr/local/ssl/openssl.cnf
$ gmssl req -new -key Server.key -out Server.csr -subj /C=CN/ST=Guang\ Zhou/L=GZ/O=Server/OU=Server\ Sign/CN=ServerCA/emailAddress=Server@gmail.com -config /usr/local/ssl/openssl.cnf
$ gmssl x509 -req -sm3 -days 3650 -CA RootCA.crt -CAkey demoCA/private/Root.key -CAcreateserial -in Server.csr -out ServerCA.crt
$ gmssl verify -CAfile RootCA.crt ServerCA.crt
标签:tab param cert subject csr gnu 依赖 书签 实验环境
原文地址:https://www.cnblogs.com/mrwh/p/11558888.html