创建CA证书和SERVER服务器证书

生成CA证书

certtool --generate-privkey --outfile ca-key.pem
cat <<_EOF_> ca.tmpl
cn = "ONEXIN CA"
organization = "ONEXIN Corp"
serial = 1
expiration_days = 999
ca
signing_key
cert_signing_key
crl_signing_key
_EOF_
certtool --generate-self-signed --load-privkey ca-key.pem --template ca.tmpl --outfile ca-cert.pem

生成本地服务器证书

certtool --generate-privkey --outfile server-key.pem
cat <<_EOF_> server.tmpl
cn = "onexin.com"
organization = "ONEXIN"
serial = 2
expiration_days = 999
signing_key
encryption_key
tls_www_server
_EOF_
certtool --generate-certificate --load-privkey server-key.pem --load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem --template server.tmpl --outfile server-cert.pem

生成客户端证书

certtool --generate-privkey --outfile user-key.pem
cat <<_EOF_>user.tmpl
cn = "ONEXIN"
unit = "admins"
serial = 1824
expiration_days = 999
signing_key
tls_www_client
_EOF_
certtool --generate-certificate --load-privkey user-key.pem --load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem --template user.tmpl --outfile user-cert.pem

生成可在windows中可导入的p12格式的证书

openssl pkcs12 -export -inkey user-key.pem -in user-cert.pem -name "onexinclient" \
-certfile ca-cert.pem -caname "ONEXIN CA" -out client.cert.p12

会提示设置证书密码,也可以不设置直接回车即可。

如果是在root#提示符下操作的,生成的文件在/root文件夹下,生成之后把服务器证书server-cert.pem 放到/etc/ssl/certs,私钥server-key.pem 放到/etc/ssl/private。

cp ca-cert.pem /etc/ssl/certs
cp ca-key.pem /etc/ssl/private
cp server-cert.pem /etc/ssl/certs
cp server-key.pem /etc/ssl/private

参考创建 ca 证书和服务器证书
http://www.infradead.org/ocserv/manual.html#heading5

转载请注明出处:https://www.onexin.net/ca-server-cert/

随机文章:

1、Windows CE 6.0正式发布 源代码100%开放
https://www.onexin.net/windows-ce-60%e6%ad%a3%e5%bc%8f%e5%8f%91%e5%b8%83-%e6%ba%90%e4%bb%a3%e7%a0%81100%ef%bc%85%e5%bc%80%e6%94%be/

2、常用Rewrite规则在线生成
https://www.onexin.net/rewrite-rules-generate-common-line/

3、Supesite模板制作官方视频教程
https://www.onexin.net/supesite-templates-to-create-the-official-video-tutorials/

4、微软Surface Duo售价出来了9700元
https://www.onexin.net/surface-duo9700/

5、Discuz!X程序结构图
https://www.onexin.net/discuz-x-program-structure-diagram/

Leave a Reply