如何将PKCS#8格式的PEM私钥转换为传统格式?

发布于 2024-09-03 20:34:37 字数 253 浏览 4 评论 0原文

来自 OpenSSL 1.0 更改日志:

将 PKCS#8 设置为默认写入格式 对于私钥,替换 传统格式。这种形式是标准化的,更安全,并且不 包括隐式 MD5 依赖性。 [史蒂夫·汉森]

但是,我需要以前的传统格式的私钥文件。 是否可以将 pem 文件从 PKCS#8 转换为传统格式(使用 OpenSSL.exe 应用程序)?

非常感谢!

From OpenSSL 1.0 change log:

Make PKCS#8 the default write format
for private keys, replacing the
traditional format. This form is standardised, more secure and doesn't
include an implicit MD5 dependency.
[Steve Henson]

However, I need the private key file in the previous, traditional format.
Is it possible to convert the pem file from PKCS#8 to the traditional format (using OpenSSL.exe app)?

Thank you very much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三五鸿雁 2024-09-10 20:34:37

成功地以这种方式解决了这个问题 -
请求:

openssl req -configconfigfile.cfg -newkey rsa:2048 -keyout newkey.pem -out newreq.pem 365

然后,我将其转换为 RSA 格式:

openssl rsa -in newkey.pem -out newkey.pem

希望它会对某人有所帮助。

Succeeded to solve that in that way -
the request:

openssl req -configconfigfile.cfg -newkey rsa:2048 -keyout newkey.pem -out newreq.pem 365

Then, I converted it to RSA format:

openssl rsa -in newkey.pem -out newkey.pem

Hope that it will help someone.

傾城如夢未必闌珊 2024-09-10 20:34:37

使用 Openssl 3.0 :https://www.openssl.org/docs /man3.0/man1/openssl-pkey.html

从 PKCS#1 转换为 PKCS#8:

$ cat pkcs1.pem
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
$ openssl pkey -in pkcs1.pem
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----

从 PKCS#8 转换为 PKCS#1:

$ cat pkcs8.pem
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
$ openssl pkey -in pkcs8.pem -traditional
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----

请参阅 https://stackoverflow.com/a/20065522/2162144 了解 PKCS#1 与 PKCS#8 的说明。

Using Openssl 3.0 :https://www.openssl.org/docs/man3.0/man1/openssl-pkey.html

Convert from PKCS#1 to PKCS#8:

$ cat pkcs1.pem
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
$ openssl pkey -in pkcs1.pem
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----

Convert from PKCS#8 to PKCS#1:

$ cat pkcs8.pem
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
$ openssl pkey -in pkcs8.pem -traditional
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----

See https://stackoverflow.com/a/20065522/2162144 for a description of PKCS#1 vs PKCS#8.

抱着落日 2024-09-10 20:34:37

RSA 私钥

要从 PKCS#1 转换为 PKCS#8:

openssl pkcs8 -topk8 -inform pem -in private_pkcs1.pem -outform pem -nocrypt \
 -out private_pkcs8.pem

要从 PKCS#8 转换为 PKCS#1(对于 OpenSSL <= 1.1,请删除 -traditional 开关):

openssl rsa -in private_pkcs8.pem -out private_pkcs1.pem -traditional

RSA 公钥

从 PKCS#1 转换为 PKCS#8:

openssl rsa -RSAPublicKey_in -in public_pkcs1.pem -pubout -out public_pkcs8.pem

从 PKCS#8 转换为 PKCS#1(对于 OpenSSL <= 1.1,删除 -traditional 开关):

openssl rsa -pubin -in public_pkcs8.pem -RSAPublicKey_out -out public_pkcs1.pem -traditional

RSA private key

To convert from PKCS#1 to PKCS#8:

openssl pkcs8 -topk8 -inform pem -in private_pkcs1.pem -outform pem -nocrypt \
 -out private_pkcs8.pem

To convert from PKCS#8 to PKCS#1 (for OpenSSL <= 1.1 remove the -traditional switch):

openssl rsa -in private_pkcs8.pem -out private_pkcs1.pem -traditional

RSA public key

To convert from PKCS#1 to PKCS#8:

openssl rsa -RSAPublicKey_in -in public_pkcs1.pem -pubout -out public_pkcs8.pem

To convert from PKCS#8 to PKCS#1 (for OpenSSL <= 1.1 remove the -traditional switch):

openssl rsa -pubin -in public_pkcs8.pem -RSAPublicKey_out -out public_pkcs1.pem -traditional
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文