1、生成SM2私钥及证书请求
gmssl ecparam -genkey -name sm2p256v1 -text -out user.key
gmssl req -new -key user.key -out user.req
2、用私钥对csr进行自签名
gmssl x509 -req -days 3650
-sm3 -in user.req -signkey user.key -out user.crt
3、把crt转cer
gmssl x509 -inform pem -
in
user.crt -outform der -out user.cer
4、查看证书内容:
<span style="color:#567482">pet\crt格式(begin..end格式base64):</span>
<span style="color:#567482">gmssl x509 -in user.crt -text -noout</span>
der\cer(hex)格式:
gmssl x509 -in user.cer -inform der -text -noout
<span style="background-color:#f4f4f4">参考:</span>
<span style="background-color:#f4f4f4">http://gmssl.org/docs/quickstart.html
</span>
<span style="background-color:#f4f4f4"><a data-cke-saved-href="http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=29199121&id=4424058" href="http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=29199121&id=4424058">http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=29199121&id=4424058</a>
</span>
<span style="background-color:#f4f4f4">http://www.cnblogs.com/StephenWu/p/6791714.html
</span>
<a data-cke-saved-href="http://www.cnblogs.com/guogangj/p/4118605.html" href="http://www.cnblogs.com/guogangj/p/4118605.html">http://www.cnblogs.com/guogangj/p/4118605.html</a>
<span style="background-color:#f4f4f4">
</span>
发现两篇好文:
1、sm2加解密demo,c语言实现;
https://www.cnblogs.com/bigben0123/p/12852501.html
2、sm2加解密注意事项,如公钥前添加0x04,sm2加密后密文顺序等,新版本是C1|C3|C2
https://blog.csdn.net/yinianjian2017/article/details/79896903