如何从 Java 密钥库创建 PFX 文件?

发布于 2024-07-13 07:36:13 字数 57 浏览 4 评论 0原文

我有一个包含单个证书的 Java 密钥库(.jks 文件)。 如何从此密钥库创建 .pfx 文件?

I have a Java keystore (.jks file) holding a single certificate. How can I create a .pfx file from this keystore?

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

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

发布评论

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

评论(4

梦幻之岛 2024-07-20 07:36:14

从 Java 6 开始,keytool 有一个 -importkeystore 选项,它应该能够将 JKS 存储转换为 PKCS#12 存储 (.p12/.pfx)

keytool -importkeystore -srckeystore thekeystore.jks \
            -srcstoretype JKS \
            -destkeystore thekeystore.pfx \
            -deststoretype PKCS12

:会要求您输入源文件和目标文件(jks、pfx)的密码

From Java 6 onwards, keytool has an -importkeystore option, which should be able to convert a JKS store into a PKCS#12 store (.p12/.pfx):

keytool -importkeystore -srckeystore thekeystore.jks \
            -srcstoretype JKS \
            -destkeystore thekeystore.pfx \
            -deststoretype PKCS12

It will ask you to enter a password for source and destination (jks, pfx) files

安人多梦 2024-07-20 07:36:14

这个家伙()似乎写了一个小Java类和批处理文件,并提供了很好的说明,可以在这里执行此操作:http://www.crionics.com/products/opensource/faq/signFree.htm#DownloadTools

如果您想自己动手,.bat 文件中的关键行似乎是使用

keytool -export -rfc -keystore %KEYSTORE% -storepass %PASSWORD% -alias %ALIAS% > %CERT_64%
java -classpath %JAVACLASSPATH% ExportPrvKey %KEYSTORE% %PASSWORD% %ALIAS% > %PKEY_8%
openssl enc -in %PKEY_8% -a >> %PKEY_64%
openssl pkcs12 -inkey %PKEY_64% -in %CERT_64% -out %CERT_P12% -export

ExportPrvKey 执行从密钥库中提取私钥的步骤。

This guy() seems to have written a little Java class and batch file with good instructions to do this here: http://www.crionics.com/products/opensource/faq/signFree.htm#DownloadTools

If you want to do it yourself the key lines in the .bat file seem to be uses

keytool -export -rfc -keystore %KEYSTORE% -storepass %PASSWORD% -alias %ALIAS% > %CERT_64%
java -classpath %JAVACLASSPATH% ExportPrvKey %KEYSTORE% %PASSWORD% %ALIAS% > %PKEY_8%
openssl enc -in %PKEY_8% -a >> %PKEY_64%
openssl pkcs12 -inkey %PKEY_64% -in %CERT_64% -out %CERT_P12% -export

where ExportPrvKey does the step of extracting the private key from the keystore.

小梨窩很甜 2024-07-20 07:36:14

keytool -importkeystore -srckeystore [MY_KEYSTORE.jks] -destkeystore [MY_FILE.p12] -srcstoretype JKS -deststoretype PKCS12

然后它会请求您的密码和 BAM - 很好,昨晚刚刚尝试过,效果很好。

您可能必须首先将目录更改为 java jdk 或 jre bin 文件夹,然后包含当前密钥库和 dest .p12 文件的完整路径。

keytool -importkeystore -srckeystore [MY_KEYSTORE.jks] -destkeystore [MY_FILE.p12] -srcstoretype JKS -deststoretype PKCS12

Then it will request your passphrases and BAM - good to go, tried just last night worked great.

you may have to change dir to your java jdk, or jre bin folder first, then include a full path to your current Keystore, and dest .p12 file.

天气好吗我好吗 2024-07-20 07:36:14

您可以使用以下命令导出包含私钥的 PFX 文件:

keytool -importkeystore -deststorepass secret -destkeypass secret -destkeystore KEYSTOREFILE.jks -srckeystore PFXFILE.pfx -srcstoretype PKCS12 -srcstorepass secret

You can export a PFX file including private key, with the following command:

keytool -importkeystore -deststorepass secret -destkeypass secret -destkeystore KEYSTOREFILE.jks -srckeystore PFXFILE.pfx -srcstoretype PKCS12 -srcstorepass secret
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文