Overview:
I use the following code to create the keystore from the certificate file which is in resources/certificates/crt.p12:
public static KeyStore getKeyStoreFromFile(String certificateFilePath,
String certificatePassword) throws KeyStoreException {
File p12File = new File(
KeyStoreUtil.class.getClassLoader().getResource(certificateFilePath).getFile());
KeyStore.Builder builder = KeyStore.Builder.newInstance("PKCS12", null, p12File,
new KeyStore.PasswordProtection(certificatePassword.toCharArray()));
return builder.getKeyStore();
}
and it works in windows platform.
Issue:
However, when I run it on a linux platform the system cannot find the file and throws the following exception:
java.lang.IllegalArgumentException: File does not exist or it does not refer to a normal file: file:/executable/billpay-billinfo-services.jar!/certificates/crt.p12
I think it's the different platform issue and I would be grateful if any one can help me find solution for this problem.