Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I programmatically import a public key .cer file into a java keystore using JSSE?

Tags:

java

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!

like image 859
J P Avatar asked Jun 17 '09 00:06

J P


People also ask

How do I import a public key into Truststore?

You cannot import the key into your trust store - you need a certificate for that. You can either ask for a certificate or write code to decrypt the bearer token with the public key directly.


1 Answers

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

like image 178
akarnokd Avatar answered Sep 23 '22 05:09

akarnokd