Kaspersky Security Center

将 PFX 证书转换为 PEM 格式

2024年5月6日

ID 201428

要在 Kaspersky Security Center Web Console 中使用 PFX 证书,必须首先使用任何方便的基于 OpenSSL 的跨平台实用程序将该证书转换为 PEM 格式。

要在 Windows 操作系统中将 PFX 证书转换为 PEM 格式:

  1. 在基于 OpenSSL 的跨平台实用程序中,执行以下命令:

    openssl pkcs12 -in <filename.pfx> -clcerts -nokeys -out server.crt

    openssl pkcs12 -in <filename.pfx> -nocerts -nodes -out key.pem

    结果,您将得到一个 .crt 文件形式的公钥和一个受密码保护的 .pem 文件形式的私钥。

  2. 确保 .crt 和 .pem 文件生成到存储 .pfx 文件的同一文件夹中。
  3. 如果 .crt 或 .pem 文件包含包属性,则使用任何方便的文本编辑器删除这些属性,然后保存文件。
  4. 重新启动 Windows 服务。
  5. Kaspersky Security Center Web Console 不支持受密码保护的证书。因此,在基于 OpenSSL 的跨平台实用程序中运行以下命令,从 .pem 文件中删除密码:

    openssl rsa -in key.pem -out key-without-passphrase.pem

    输入和输出 .pem 文件不要使用相同名称。

    结果,新的 .pem 文件未加密。无需输入密码即可使用。

.crt 和 .pem 文件已可以使用,因此您可以在 Kaspersky Security Center Web Console 安装程序中指定它们。

要在 Linux 操作系统中将 PFX 证书转换为 PEM 格式:

  1. 在基于 OpenSSL 的跨平台实用程序中,执行以下命令:

    openssl pkcs12 -in <filename.pfx> -clcerts -nokeys | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > server.crt

    openssl pkcs12 -in <filename.pfx> -nocerts -nodes | sed -ne '/-BEGIN PRIVATE KEY-/,/-END PRIVATE KEY-/p' > key.pem

  2. 确保证书文件和私钥生成到存储 .pfx 文件的同一目录中。
  3. Kaspersky Security Center Web Console 不支持受密码保护的证书。因此,在基于 OpenSSL 的跨平台实用程序中运行以下命令,从 .pem 文件中删除密码:

    openssl rsa -in key.pem -out key-without-passphrase.pem

    输入和输出 .pem 文件不要使用相同名称。

    结果,新的 .pem 文件未加密。无需输入密码即可使用。

.crt 和 .pem 文件已可以使用,因此您可以在 Kaspersky Security Center Web Console 安装程序中指定它们。

Did you find this article helpful?
What can we do better?
Thank you for your feedback! You're helping us improve.
Thank you for your feedback! You're helping us improve.