安装VS后makecert.exe即可使用,打开CMD后输入makecert,然后输入参数:
makecert -r -pe -n “cn=gbcar” -$ commercial -a sha1 -b 08/05/2010 -e 01/01/2012 -cy authority -ss my -sr currentuser
参数意义:
-r: 自签名
-pe: 将所生成的私钥标记为可导出。这样可将私钥包括在证书中。
-n “cn=gbcar”: 证书的subject name,.net自带类库中有X509Store类,可以在store中根据证书subject name,来找到改证书
store参考:
-$ commercial:指明证书商业使用。
-a:指定签名算法。必须是 md5(默认值)或 sha1。
-b 01/01/2021:证书有效期的开始时间,默认为证书的创建日期。格式为:mm/dd/yyyy
-e 12/31/2030:指定有效期的结束时间。默认为 12/31/2039 11:59:59 GMT。格式同上
-ss my:证书产生到my个人store区
-sr currentuser:保持到计算机当前个人用户区,其他用户登录系统后则看不到该证书。
PKCS#12规范的证书,包含了公钥和私钥,导出时需要提供一个私钥的保护密码,在导出时设置即可:





—结束—