如何做CRT

2020-11-11  本文已影响0人  若罗

首先看概念
https://zhuanlan.zhihu.com/p/26684050

得知我们需要根证书(CA)以及某个服务的证书。
假设根证书是example.com
服务证书是httpbin.example.com

第一步,创建根证书的私钥公钥对
openssl genrsa -des3 -out withpass.example.com.key 2048
openssl rsa -in withpass.example.com.key -out example.com.key

第二步,创建根证书,可能会报rnd警告,可以用openssl rand -writerand .rnd解决
openssl req -new -x509 -key example.com.key -out example.com.crt -days 3650 -subj '/O=example Inc./CN=example.com'

第三步,创建服务的私钥公钥对
openssl genrsa -des3 -out withpass.httpbin.example.com.key 2048
openssl rsa -in withpass.httpbin.example.com.key -out httpbin.example.com.key

第四步,创建服务的证书CSR
openssl req -new -key httpbin.example.com.key -out httpbin.example.com.csr -subj '/CN=httpbin.example.com/O=httpbin organization'

第五步,用CA的证书来生成服务的证书
openssl x509 -req -days 365 -CA example.com.crt -CAkey example.com.key -set_serial 0 -in httpbin.example.com.csr -out httpbin.example.com.crt

上一篇 下一篇

猜你喜欢

热点阅读