.P7B 轉(zhuǎn)換為 .PFX
1、下載openssl工具,(這里以windows系統(tǒng)為例)
????https://www.chinassl.net/download/d1.html
2、格式轉(zhuǎn)換
P7B (PKCS#7)
一個(gè)P7B文件是一個(gè)包含證書和證書鏈的文本文件,但不包含私鑰。
PFX (PKCS#12)
為存儲(chǔ)和傳輸用戶或服務(wù)器私鑰、公鑰和證書指定了一個(gè)可移植的格式。它是一種二進(jìn)制格式,這些文件也稱為PFX文件。
轉(zhuǎn)換 P7B 為 PFX
需要注意的是,為了做轉(zhuǎn)換,你必須擁有證書cert.p7b文件和私鑰cert.key文件。
$ openssl pkcs7 -print_certs -in cert.p7b -out cert.cer
-
-print_certs: 輸出文件中包含的任何證書.
-
-in: 指定輸入文件.
-
-out: 指定輸出文件.
$ openssl pkcs12 -export -in cert.cer -inkey cert.key -out cert.pfx
-
-export: 表示導(dǎo)出證書.
-
-in:指定 PKCS#12 的文件名.
-
-inkey: 指定私鑰文件名.
-
-out: 指定輸出文件.
3、擴(kuò)展:
創(chuàng)建自簽名的證書
創(chuàng)建2048 位的 RSA證書, 有效期為5年:
$ openssl req -new -x509 -days 1825 -sha256 -nodes -out cert.crt -keyout cert.key
-
req: 產(chǎn)生證書簽發(fā)申請命令
-
-new: 表示新的請求.
-
-x509: 簽發(fā)X.509格式證書命令.
-
-days: 表示有效天數(shù).
-
-sha256: 表示證書摘要算法,這里為SHA256.
-
-nodes: 私鑰將不會(huì)被加密.
-
-out: 指定輸出文件名.
-
-keyout: 指定新創(chuàng)建的私鑰的文件名.
$ openssl pkcs12 -export -in cert.crt -inkey cert.key -out cert.pfx
創(chuàng)建一個(gè)證書請求 (CSR)
$ openssl req -new -newkey rsa:2048 -sha256 -nodes -out cert.csr -keyout cert.key
-newkey :創(chuàng)建一個(gè)新的證書請求和KEY.
注意:“Country Name”必須為“CN”,其他字段可以隨意填寫。
創(chuàng)建RSA私鑰為PFX
$ openssl pkcs12 -in cert.pfx -nocerts -nodes | openssl rsa -out rsaprivkey.pem
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載。
THE END