I’m trying to retrieve entries from a Java KeyStore on Mac OSX 10.6. My code runs fine on Windows and Linux, but when I run it on OSX I get the following Exception:
java.lang.UnsupportedOperationException
at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:466)
at java.security.KeyStore.getEntry(KeyStore.java:1261)
Here’s my code:
String keyStorePath = ...
PasswordProtection pp = new PasswordProtection("password".toCharArray());
CallbackHandlerProtection chp = new CallbackHandlerProtection(
new CallbackHandler() {
@Override
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof PasswordCallback) {
PasswordCallback pc = (PasswordCallback) callbacks[i];
pc.setPassword("password".toCharArray());
}
}
}
});
try {
KeyStore.Builder kb = Builder.newInstance("JCEKS", null, new File(
keyStorePath), chp);
KeyStore ks = kb.getKeyStore();
Enumeration<String> aliases = ks.aliases();
while (aliases.hasMoreElements()) {
String alias = aliases.nextElement();
KeyStore.Entry entry = ks.getEntry(alias, chp);
}
} catch (Exception e) {
e.printStackTrace();
}
Any idea why this exception is being thrown on OSX? Is it a bug in the JVM on this OS? Anyone ever seen this before?
Looks to be a bug in Apple’s implementation of the JVM. I’ve submitted a bug report. Thanks for your help!