Apache-2.2

如何將各種證書組合成單個 .pem

  • June 21, 2016

我剛剛讀完這個解釋不同 SSL 格式的精彩執行緒。

現在我基本上在尋找與如何拆分 PEM 文件相反的東西

我要合併 4 個文件,最初是為 Apache 創建的,我正在查看由指定的文件

  • SSL證書文件
  • SSL證書密鑰文件
  • SSL證書鏈文件
  • SSLCAC證書文件

我最好奇的是合併衍生文件中文件的順序,這重要嗎?例如。如果我cat按照上面出現的順序將它們放在一起,變成*.pem*,它是否有效,或者應該以特定的方式訂購它們?

僅供參考,我這樣做是為了將這些證書用作SimpleSAMLphp中的組合單個*.pem*。

根據RFC 4346 ,順序確實很重要。

這是直接取自 RFC 的引用:

 certificate_list
   This is a sequence (chain) of X.509v3 certificates.  The sender's
   certificate must come first in the list.  Each following
   certificate must directly certify the one preceding it.  Because
   certificate validation requires that root keys be distributed
   independently, the self-signed certificate that specifies the root
   certificate authority may optionally be omitted from the chain,
   under the assumption that the remote end must already possess it
   in order to validate it in any case.

根據這些資訊,伺服器證書應該放在第一位,然後是任何中間證書,最後是根可信授權證書(如果是自簽名的)。我找不到有關私鑰的任何資訊,但我認為這無關緊要,因為 pem 中的私鑰很容易辨識,因為它以下面的文本開頭和結尾,其中包含關鍵字PRIVATE

-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----

引用自:https://serverfault.com/questions/476576