当前位置:   article > 正文

openssl命令行生成SM2证书_openssl sm2

openssl sm2

根证

#获取曲线参数
openssl ecparam -list_curves

#生成SM2的密钥
openssl ecparam -genkey -name SM2 -text -out Root.key

#生成证书请求文件
openssl req -config /etc/pki/tls/openssl.cnf  -key Root.key -new -out Root.req

#生成证书
openssl x509 -req -days 3650 -sm3 -in Root.req -signkey Root.key -out RootCA.crt

#查看DER证书
openssl x509 -in RootCA.crt -text -noout
openssl x509 -in /home/admin/user_data/cert/strongbox/ca.cer -inform DER -text

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

用户证书

#生成私钥
openssl ecparam -genkey -name SM2 -text -out Server.key 

#证书请求
openssl req -new -key Server.key -subj /C=CN/CN=cmq1 -out Server.req 

#签发证书
openssl x509 -req -sm3 -days 3650 -CA RootCA.crt -CAkey Root.key -CAcreateserial -in Server.req -out ServerCA.crt 

#证书验证
openssl verify -CAfile RootCA.crt ServerCA.crt 

#查看证书
openssl x509 -in ServerCA.crt -text -noout 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

通信验证

#服务端
openssl s_server -accept 443 -key Server.key -cert ServerCA.crt -dkey Server.key -dcert ServerCA.crt -CAfile RootCA.crt -msg -debug 

#客户端
openssl s_client -connect 127.0.0.1:443 -key Client.key -cert ClientCA.crt -CAfile RootCA.crt -msg -debug 
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/363193
推荐阅读
相关标签
  

闽ICP备14008679号