如何在java中加载使用des加密的rsa私钥

发布于 2024-09-27 14:38:02 字数 194 浏览 3 评论 0原文

在我的工作中,我被分配了一项任务,其中我必须以编程方式从文件加载私钥和公钥,然后将它们存储在 .jks 文件中,私钥是使用 openssl 生成的,它是 der 格式的 rsa des 加密密钥,我加载公钥没有问题,但是,我还没有找到以原始形式加载私钥的方法,我发现的唯一方法是解密密钥然后将其转换为 pk8 文件,它有任何还有其他方法可以在不解密私钥的情况下做到这一点吗?

in my job i was assigned a task in which i have to programmatically load a private and public keys from files and then store them in a .jks file,the private key was generated using openssl, its an rsa des encrypted key in der format,i have no problem loading the public key, however,i haven't found a way to load the private key in its original form, the only way i found consist in decrypt the key and then convert it to a pk8 file, its there any other way to do it without decrypting the private key?

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

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

发布评论

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

评论(1

一指流沙 2024-10-04 14:38:02

OpenSSL 保存密钥的标准方法是使用 PEM 格式(PEM 页眉和页脚以及内部的 base64 编码的 DER 密钥)。私钥另外加密(加密算法在标头中指定)。 JKS 不使用 DER 来加密私钥,因此您不能只获取加密的 DER 序列并将其放入 JKS。要将密钥对添加到 JKS,您需要获取 DER 格式的公钥和私钥,并且必须解密私钥。

OpenSSL's standard way to save keys is to use PEM format (PEM header and footer and base64-encoded DER key inside). Private key is additionally encrypted (encryption algorithm is specified in header). JKS doesn't use DER for encryption of the private key, so you can't just take the encrypted DER sequence and put it to JKS. To add the keypair to JKS you need to get both public and private key in DER format and the private key must be decrypted.

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