天天看點

openssl續

建立私有ca:

openCA

openssl:/etc/pki/tls/openssl.cnf

(1) 建立所需要的檔案

# /etc/pki/CA

# touch index.txt

# echo 01 > serial

(2) CA自簽證書

# (umask 077; openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048)

# openssl req -new -x509 -key /etc/pki/CA/private/cakey.epm -days 7300 -out /etc/pki/CA/cacert.pem

-new: 生成新證書簽署請求;

-x509: 專用于CA生成自簽證書;

-key: 生成請求時用到的私鑰檔案;

-days n:證書的有效期限;

-out /PATH/TO/SOMECERTFILE: 證書的儲存路徑;

(3) 發證

(a) 用到證書的主機生成證書請求;

# (umask 077; openssl genrsa -out /etc/httpd/ssl/httpd.key 2048)

# openssl req -new -key /etc/httpd/ssl/httpd.key -days 365 -out /etc/httpd/ssl/httpd.csr

(b) 把請求檔案傳輸給CA;

(c) CA簽署證書,并将證書發還給請求者;

# openssl ca -in /tmp/httpd.csr -out /etc/pki/CA/certs/httpd.crt -days 365

檢視證書中的資訊:

openssl x509 -in /PATH/FROM/CERT_FILE -noout -text|-subject|-serial

(4) 吊銷證書

(a) 用戶端擷取要吊銷的證書的serial

# openssl x509 -in /PATH/FROM/CERT_FILE -noout -serial -subject

(b) CA

先根據客戶送出的serial與subject資訊,對比檢驗是否與index.txt檔案中的資訊一緻;

吊銷證書:

# openssl ca -revoke /etc/pki/CA/newcerts/SERIAL.pem

(c) 生成吊銷證書的編号(第一次吊銷一個證書)

# echo 01 > /etc/pki/CA/crlnumber

(d) 更新證書吊銷清單

# openssl ca -gencrl -out thisca.crl

檢視crl檔案:

# openssl crl -in /PATH/FROM/CRL_FILE.crl -noout -text

證書申請及簽署步驟:

1、生成申請請求;

2、RA核驗;

3、CA簽署;

4、獲驗證書;

      本文轉自echoroot 51CTO部落格,原文連結:http://blog.51cto.com/echoroot/1947329,如需轉載請自行聯系原作者

繼續閱讀