我可以将没有证书的 RSA 公钥存储到我现有的 jks 文件中吗? [英] Can I store RSA public key without certificate to my existing jks file?

查看:103
本文介绍了我可以将没有证书的 RSA 公钥存储到我现有的 jks 文件中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 RSA 公钥(没有证书),我想将它添加到我现有的 jks 文件中.

I am having a RSA public key (without certificate) which I want to add in my existing jks file.

-----BEGIN PUBLIC KEY-----
MIIBIjA.... // key here
-----END PUBLIC KEY-----

有可能吗?我没有它的私钥,所以如果我用其他密钥创建一个自签名证书,它会起作用吗(我认为不会)?

Is it possible? I don't have private key of it so if I create a self signed certificate with other key will it work (I think it won't)?

推荐答案

Java 密钥库只能存储密钥、密钥对(私钥 + 证书链)和证书.公钥不能独立存在,它们通常嵌入在证书中.

Java keystores can only store Secret Keys, Key Pairs (private key + certificate chain) and Certificates. Public keys cannot stand on their own, they are usually embedded in the certificate.

所以要回答你的问题,你不能存储你的公钥.您需要与向您提供公钥的人合作,看看他们是否可以为您提供证书.并且您无法创建自签名证书,因为您没有其私钥,并且您也无法使用其他私钥.

So to answer your question, you cannot store your public key. You need to work with whoever provided you the public key and see if they can provide you the certificate. And you cannot create a self-signed certificate because you don't have its private key, and you won't be able to use a different private key either.

如果你需要在代码中使用你的公钥,这个解决方案 向您展示了如何做到这一点,前提是您将公钥存储为文件.

If you need to use your public key in code, this solution shows you how to do it provided you store your public key as a file.

这篇关于我可以将没有证书的 RSA 公钥存储到我现有的 jks 文件中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆