首頁  >  文章  >  運維  >  .P7B 憑證如何轉換為 .PFX

.P7B 憑證如何轉換為 .PFX

WBOY
WBOY轉載
2023-05-13 21:04:042779瀏覽

.P7B 轉換為.PFX

1、下載openssl工具,(這裡以windows系統為例)

    https://www. chinassl.net/download/d1.html

2、格式轉換

P7B (PKCS#7)

一個P7B文件是一個包含憑證和憑證鏈的文字文件,但不包含私鑰。

PFX (PKCS#12)

為儲存和傳輸使用者或伺服器私鑰、公鑰和憑證指定了一個可移植的格式。它是一種二進位格式,這些檔案也稱為PFX檔。

轉換 P7B 為 PFX

要注意的是,為了做轉換,你必須擁有憑證cert.p7b檔案和私鑰cert.key檔。

$ openssl pkcs7 -print_certs -in cert.p7b -out cert.cer
  1. -print_certs: 輸出檔案中包含的任何憑證.

  2. -in: 指定輸入檔.

  3. -out: 指定輸出檔.

$ openssl pkcs12 -export -in cert.cer -inkey cert.key -out cert.pfx
  1. -export: 表示匯出憑證.

  2. -in:指定PKCS#12 的檔案名稱.

  3. -inkey: 指定私鑰檔案名稱.

  4. #-out: 指定輸出檔.

3、擴充:

建立自簽署的憑證

建立2048 位元的RSA證書,有效期限為5年:

$ openssl req -new -x509 -days 1825 -sha256 -nodes -out cert.crt \
-keyout cert.key
  1. req: 產生憑證簽發申請指令

  2. -new: 表示新的請求.

  3. -x509: 簽發X.509格式憑證指令.

  4. -days: 表示有效天數.

  5. -sha256: 表示憑證摘要演算法,這裡為SHA256.

  6. -nodes : 私鑰將不會被加密.

  7. -out: 指定輸出檔名.

  8. -keyout: 指定新建立的私鑰的檔案名稱.

$ openssl pkcs12 -export -in cert.crt -inkey cert.key -out cert.pfx

建立一個憑證要求(CSR)

$ openssl req -new -newkey rsa:2048 -sha256 -nodes -out cert.csr \
-keyout cert.key

- newkey :建立一個新的憑證要求和KEY.

注意:「Country Name」必須為「CN」,其他欄位可以隨意填寫。

建立RSA私鑰為PFX

$ openssl pkcs12 -in cert.pfx -nocerts -nodes | openssl rsa -out rsaprivkey.pem

以上是.P7B 憑證如何轉換為 .PFX的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除