将 .pk8 文件转换为 .key 文件
我有一个 .pk8 文件,我想将其转换为 .key 文件格式,以便我可以将它们移动到 pkcs12 存储中,然后使用 keytool 移动到 java 密钥存储中。
请提出可能的解决方案?
I have a .pk8 file and I want to convert it into .key file format,so that I can move them into a pkcs12 store and then later to java keystore using keytool.
Please suggest possible solutions??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先使用 OpenSSL 命令行工具将您的 PKCS#8 文件转换为普通私钥:
如果这给您带来错误,可能是因为密钥采用 DER 格式,请尝试以下操作:
收集您想要在 PKCS 中使用的证书#12 密钥存储并确保它们是 PEM 编码的(在文本编辑器中打开它们 - 如果文件以“----- BEGIN X.509 CERTIFICATE -----”或类似内容开头,那么你已经很好了到go):
打开文本编辑器,然后将所有 PEM 编码的证书加上 key.pem 的内容粘贴到该文件中,一个接一个地获取如下文件:
保存此文件,例如 as all .pem。要最终创建 PKCS#12 密钥存储,请发出以下命令:
提供密码即可完成。
name
参数将成为您在 Java 世界中的“别名”。Use the OpenSSL command line tool to convert your PKCS#8 file to a plain private key first:
If that gives you an error it's probably because the key is in DER format, try this then:
Gather the certificates you want to be in your PKCS#12 key store and make sure they are PEM-encoded (open them in a text editor - if the file starts with '----- BEGIN X.509 CERTIFICATE -----' or similar then you're already good to go):
Open a text editor and paste all the PEM-encoded certificates plus the contents of key.pem in that file, one after the other to get a file like this:
Save this, e.g. as all.pem. To finally create your PKCS#12 key store, issue this command:
Provide a password and your done. The
name
parameter is going to be your "alias" in the Java world.遵循本指南对我有用。具体使用 keytool-iui 导入私钥。
Following this guide worked for me. Specifically using keytool-iui to import the private key.