简体   繁体   中英

Can I store RSA public key without certificate to my existing jks file?

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM