Reputation: 25
Am trying to read the installed certificates by using code
KeyStore ks = KeyStore.getInstance("Windows-MY")
ks.load(null, null)
Enumeration<String> enumeration = ks.aliases()
while (enumeration.hasMoreElements()) {
String string = (String) enumeration.nextElement()
System.out.println(string)
}
this code list out the installed certificates on windows but on linux doesn't? tried by changing the keystore providers also.
Upvotes: 2
Views: 1302
Reputation: 732
You can get the Default Type. Try the below code
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
Upvotes: 0
Reputation: 12748
Try with libsoftokn3.so
of NSS.
See my answer here, "Approach 1".
The key is to find where libsoftokn3.so
is, and use it as the libfile to construct a config file, and then a KeyStore.
Upvotes: 0
Reputation: 1531
I'm not sure what you mean with "read browsers certificates". Are you trying to read certificates from the default Java keystore? What's your goal?
KeyStore.getInstance(..) instantiates a keystore with a specific type (JKS, for example). When you want to read from a specific keystore, you need to specify the path to the keystore and make the KeyStore instance load that file.
See http://www.java2s.com/Code/Java/Security/RetrievingaKeyPairfromaKeyStore.htm for an example and https://docs.oracle.com/javase/8/docs/api/java/security/KeyStore.html for more details.
Edited: updated answer after clarified question.
You can find more info on reading browser keystores in Linux on:
Upvotes: 1