參考鏈接
- 國密自簽名證書生成_三雷科技的博客-CSDN博客_國密證書生成
- openssl采用sm2進行自簽名的方法_dong_beijing的博客-CSDN博客_openssl sm
前提說明
- OpenSSL 1.1.1q ?5 Jul 2022? 已經實現了國密算法
- 查看是否支持SM2算法
- openssl ecparam -list_curves | grep -i sm2
- 參考鏈接??openssl實現雙向認證教程(服務端代碼+客戶端代碼+證書生成)_MY CUP OF TEA的博客-CSDN博客
- 因為事先并未指定,因此生成私鑰的第二步需要輸入相關信息,
- 例如:/C=CN/ST=GD/L=SZ/O=COM/OU=NSP/CN=CA/emailAddress=ca_email@qq.com
層次結構
?
- ?為了兼容代碼中的名字,名字可能會和下面操作生成文件的名字之間出現出路
CA操作流程
- 生成私鑰
- openssl ecparam -genkey -name SM2 -param_enc explicit -outform pem -out ec_prikey_ca.key
- openssl req -new -key ec_prikey_ca.key -out ec_ca.csr
- 生成證書
- openssl x509 -req -days 365 -in ec_ca.csr -signkey ec_prikey_ca.key -out ec_ca.crt?
server操作流程
- 生成私鑰
- openssl ecparam -genkey -name SM2 -param_enc explicit -outform pem -out server.key
- openssl req -new -key server.key -out server.csr
- 生成證書
- openssl x509 -req -days 365 -in server.csr -signkey /home/chy-cpabe/ssl_server_client/ca/ec_prikey_ca.key -out server.crt
client操作流程
- 生成私鑰
- openssl ecparam -genkey -name SM2 -param_enc explicit -outform pem -out client.key
- openssl req -new -key client.key -out client.csr
- 生成證書
- openssl x509 -req -days 365 -in client.csr -signkey /home/chy-cpabe/ssl_server_client/ca/ec_prikey_ca.key -out client.crt
查看證書
- 查看證書的命令
- openssl x509 -text -in CaCert.crt
- 使用命令驗證公鑰以及參數和證書是否對應
- sudo openssl ec -in ec_prikey_ca.key -pubout -noout -text?
?