java.io.IOException: Invalid Keystore format

匿名 (未验证) 提交于 2019-12-03 02:14:01

问题:

Does anyone know how to solve this? I tried many things, but none of them worked.

And when I click more details I get this:

at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source) atsun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source) at java.security.KeyStore.load(Unknown Source) at com.sun.deploy.security.RootCertStore$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.deploy.security.RootCertStore.loadCertStore(Unknown Source) at com.sun.deploy.security.RootCertStore.load(Unknown Source) at com.sun.deploy.security.RootCertStore.load(Unknown Source) at com.sun.deploy.security.ImmutableCertStore.load(Unknown Source) at com.sun.deploy.security.TrustDecider.isAllPermissionGranted(Unknown Source) at com.sun.deploy.security.TrustDecider.isAllPermissionGranted(Unknown Source) at sun.plugin.security.PluginClassLoader.getPermissions(Unknown Source) at java.security.SecureClassLoader.getProtectionDomain(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at sun.applet.AppletClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.applet.AppletClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.applet.AppletClassLoader.loadCode(Unknown Source) at sun.applet.AppletPanel.createApplet(Unknown Source) at sun.plugin.AppletViewer.createApplet(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 

回答1:

You may corrupt the file during copy/transfer.

Are you using maven? If you are copying keystore file with "filter=true", you may corrupt the file.

Please check the file size.



回答2:

Maybe maven encoding you KeyStore, you can set filtering=false to fix to problem.

     ...                  ...                          false             ...         


回答3:

(Re)installing the latest JDK (e.g. Oracle's) fixed it for me.

Prior to installing the latest JDK, when I executed the following command in Terminal.app:

keytool -list -keystore $(/usr/libexec/java_home)/jre/lib/security/cacerts -v 

It resulted in:

keytool error: java.io.IOException: Invalid keystore format java.io.IOException: Invalid keystore format     at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:650)     at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:55)     at java.security.KeyStore.load(KeyStore.java:1445)     at sun.security.tools.keytool.Main.doCommands(Main.java:792)     at sun.security.tools.keytool.Main.run(Main.java:340)     at sun.security.tools.keytool.Main.main(Main.java:333) 

But, after installing the latest Oracle JDK and restarting Terminal, executing the following command:

keytool -list -keystore $(/usr/libexec/java_home)/jre/lib/security/cacerts -v 

Results in:

Enter keystore password:   

Which indicates that the keytool on path can access the keystore.



回答4:

I think the keystore file you want to use has a different or unsupported format in respect to your Java version. Could you post some more info of your task?

In general, to solve this issue you might need to recreate the whole keystore (using some other JDK version for example). In export-import the keys between the old and the new one - if you manage to open the old one somewhere else.

If it is simply an unsupported version, try the BouncyCastle crypto provider for example (although I'm not sure If it adds support to Java for more keystore types?).

Edit: I looked at the feature spec of BC.



回答5:

Your keystore is broken, and you will have to restore or regenerate it.



回答6:

I ran into the problem with openJDK on ubuntu, had to install Oracle JDK to get it working.

You can follow this guide on google sites to do that.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!