I am facing java.io.EOFException when i call load method by passing keystore. I have .jks file. File is loaded correctly and i could read and print the data from file.
tried with different .jks files tried to modify the code here and there by passing password as null etc.
try {
KeyStore keyStore = KeyStore.getInstance("JKS");
logger.info("No Issues till line 115");
FileInputStream keyFileStream = new
FileInputStream("C:\\Users\\Path\\Certificates\\default.jks");
// printing the data from the file to check if file is loaded
//with data
int i=0;
while((i=keyFileStream.read())!=-1){
logger.info("Reading File Data: "+(char)i);
}
try {
/*** Below line gives EOF Exception ***/
keyStore.load(keyFileStream, "password".toCharArray());
logger.info("Failed to print this line" + keyStore.size());
} finally {
keyFileStream.close();
}
}
catch (Throwable t){
logger.error("Exception occured with "+t,t);
}
Actual:
Exception occured with java.io.EOFException