如何使用 JSSE 以编程方式将公钥 .cer 文件导入到 java 密钥库中?

发布于 2024-07-24 07:30:35 字数 329 浏览 1 评论 0原文

我想获取从 java keytool 命令生成的公钥 .cer 文件,如下所示:

“keytool -export -alias privatekey -file publickey.cer -keystore privateKeys.store”

并将其导入到新的空 java 密钥库中,如下所示:

“ keytool -import -alias publiccert -file publickey.cer -keystore publicCerts.store”,

但我想使用 JSSE 以编程方式进行导入。

堆栈霸主,施展你的魔法吧! 谢谢!

I want to take a public key .cer file generated from java keytool command like this:

"keytool -export -alias privatekey -file publickey.cer -keystore privateKeys.store"

and import it into a new, empty java keystore like this:

"keytool -import -alias publiccert -file publickey.cer -keystore publicCerts.store"

except I want to do the import programmatically, using JSSE.

Stack Overlords, work your magic! Thanks!

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

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

发布评论

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

评论(2

情愿 2024-07-31 07:30:35

看一下Java中的KeyStore类。 这是一个可能会给您一些提示的课程。 您可能需要免费的 BouncyCastle 加密提供商来操作其所有功能

Look at the KeyStore class in Java. Here is a class which might give you some hints. You might require the free BouncyCastle crypto provider to operate all of its function

南风几经秋 2024-07-31 07:30:35

如果你使用jad来反编译Sun JDK自带的tools.jar,你会看到它到底是怎么回事作品。

将tools.jar解压到一个文件夹中,使用以下命令反编译所有类
在那个罐子里。

for i in $(find . -name "*.class" | perl -ple 's/\.class$//g'); do jad -p $i.class > $i.java; done

keytool 源可以在类 sun.security.tools.KeyTool 中看到

If you use jad to decompile the tools.jar that comes with Sun JDK, you will see exactly how it works.

Unzip the tools.jar in a folder and use the following command to decompile all classes
inside that jar.

for i in $(find . -name "*.class" | perl -ple 's/\.class$//g'); do jad -p $i.class > $i.java; done

The keytool source can be seen in class sun.security.tools.KeyTool

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