Reputation: 151
I want to use java key store to save keys and certificates. can anybody share some code to help me with this?
Upvotes: 10
Views: 21572
Reputation: 30089
There should be enough example code in the KeyStore Javadocs page to get you started:
As for the 'default' keystore - I'm not sure such a thing exists, normally you either load it explicitly from a file, or you can configure it using the following system properties:
And similar for the trust store:
Upvotes: 6
Reputation: 122599
There is no default keystore in Java. This is documented in the customization section of the JSSE Reference Guide.
The default trust store is:
jssecacerts, if it exists. Otherwise, cacerts
However, it doesn't mean that these are the stores used by the default SSLContext
, since it's also possible to change the default SSLContext
(since Java 6) with one that would have been initialised with custom trust managers. (See this answer for more details).
Upvotes: 5