Keystore java.io.IOException
843810Mar 31 2003 — edited Apr 1 2003Hi all, when i try to generate a secretkey and store it in a keystore, but i get an io exception for some reason.
it says:
Exception in thread "main" java.security.KeyStoreException: java.io.IOException:
Error initialising store of key store.
i really don't know what i'm doing wrong, a little bit of help would be usefull
this is a piece of my code:
private static String FILENAME = "keystore.ks";
private void registerUserKey(char[] password) throws Exception{
// Generate secret key for HMACRIPEMD160
KeyGenerator kg = KeyGenerator.getInstance("HMACRIPEMD160");
SecretKey sk = kg.generateKey();
// Create a keystore and place the key in it
// I use an UBER keystore, which is provided by Bouncycastle.
KeyStore keyStore = KeyStore.getInstance("UBER");
keyStore.load(null, null);
String alias = "exampleKey";
keyStore.setKeyEntry(alias, sk, password, null);
FileOutputStream fos = new FileOutputStream(FILENAME);
keyStore.store(fos, password);
fos.close();
}