使用OpenSSL将DER转换为PEM并将PEM转换为DER证书格式

xingyun86 2022-12-5 531

DER and PEM are formats used in X509 and other certificates to store Public, Private Keys and other related information. OpenSSL provides a lot of features for manipulating PEM and DER certificates. We can use OpenSSL to convert DER to PEM format and vice versa.

DER和PEM是X509和其他证书中使用的格式,用于存储公钥,私钥和其他相关信息。 OpenSSL提供了许多用于处理PEM和DER证书的功能。 我们可以使用OpenSSL将DER转换为PEM格式,反之亦然。

将DER格式的DER格式转换为PEM格式 (Convert DER Format To PEM Format For RSA Key)

We may have an RSA Key in DER format and we want to convert it into DER format. We will use the verbrsa with the following options.

我们可能有DER格式的RSA密钥,我们想将其转换为DER格式。 我们将把动词rsa与以下选项一起使用。

  • -inform input format

    -inform输入格式

  • -outform output format

    -outform输出格式

  • -in input

    -in输入

  • -out the output which is converted format.

    -out输出转换后的格式的输出。

$ openssl rsa -inform DER -outform PEM -in mykey.der -out mykey.pem

将PEM格式转换为RSA密钥的DER格式 (Convert PEM Format To DER Format For RSA Key)

In this step, we will do the reverse and convert PEM formatted RSA Key to the DER format with the following command.

在此步骤中,我们将执行相反的操作,并使用以下命令将PEM格式的RSA密钥转换为DER格式。

$ openssl rsa -inform PEM -outform DER -text -in mykey.pem -out mykey.der

将X509的DER格式转换为PEM格式 (Convert DER Format To PEM Format For X509)

X509 Certificates are popular especially in web sites and Operating systems. X509 certificates also stored in DER or PEM format. We can use OpenSSL to convert an X509 certificate from DER format to PEM format with the following command.

X509证书在网站和操作系统中尤其受欢迎。 X509证书也以DER或PEM格式存储。 我们可以使用OpenSSL通过以下命令将X509证书从DER格式转换为PEM格式。

$ openssl x509 -inform DER -outform PEM -text -in mykey.der -out mykey.pem

将X509的PEM格式转换为DER格式 (Convert PEM Format To DER Format For X509)

We can convert X509 certificate from PEM format to DER format with the following command.

我们可以使用以下命令将X509证书从PEM格式转换为DER格式。

$ openssl x509 -inform PEM -outform DER -text -in mykey.pem -out mykey.der
了解更多如何使用Ssh Keygen生成4096位安全Ssh密钥

翻译自: https://www.poftut.com/convert-der-pem-pem-der-certificate-format-openssl

×
打赏作者
最新回复 (0)
只看楼主
全部楼主
返回