java.io.IOException: 无效的密钥库格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1052700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:49:19  来源:igfitidea点击:

java.io.IOException: Invalid Keystore format

javaencryptionappletkeystore

提问by

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.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
keytool -list -keystore $(/usr/libexec/java_home)/jre/lib/security/cacerts -v
0(Unknown Source) at java.net.URLClassLoader.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)

回答by akarnokd

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?

我认为您要使用的密钥库文件的格式与您的 Java 版本不同或不受支持。你能发布更多关于你的任务的信息吗?

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.

通常,要解决此问题,您可能需要重新创建整个密钥库(例如,使用其他一些 JDK 版本)。在导出 - 导入新旧密钥之间的密钥时 - 如果您设法在其他地方打开旧密钥。

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

如果它只是一个不受支持的版本,例如尝试使用BouncyCastle加密提供程序(尽管我不确定它是否为更多密钥库类型添加了对 Java 的支持?)

Edit:I looked at the feature spec of BC.

编辑:我查看了 BC 的功能规范。

回答by Thorbj?rn Ravn Andersen

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

您的密钥库已损坏,您必须恢复或重新生成它。

回答by Kurtulus Oksuztepe

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.

你在用maven吗?如果您使用“filter=true”复制密钥库文件,您可能会损坏该文件。

Please check the file size.

请检查文件大小。

回答by Gary S. Weaver

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

(重新)安装最新的 JDK(例如Oracle 的)为我修复了它。

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

在安装最新的 JDK 之前,当我在 Terminal.app 中执行以下命令时:

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)

It resulted in:

结果是:

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

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

但是,在安装最新的 Oracle JDK 并重新启动终端后,执行以下命令:

Enter keystore password:  

Results in:

结果是:

<build>
    ...
    <resources>
        <resource>
            ...
            <!-- set filtering=false to fix -->
            <filtering>false</filtering>
            ...
        </resource>
    </resources>
</build>

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

这表明路径上的密钥工具可以访问密钥库。

回答by xiezefan

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

也许maven对你的KeyStore进行编码,你可以设置filtering=false来解决这个问题。

##代码##

回答by Sadiq Ali

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

我在 ubuntu 上遇到了 openJDK 的问题,必须安装 Oracle JDK 才能让它工作。

You can follow this guide on google sitesto do that.

你可以按照谷歌网站上的这个指南来做到这一点。

回答by ultimate

go to build clean the project then rebuild your project it worked for me.

去构建清理项目然后重建你的项目,它对我有用。

回答by Beaudry Jean Sauvenel

You can generate the debug keystore by running this command in the android/app/ directory: keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

您可以通过在 android/app/ 目录中运行此命令来生成调试密钥库: keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

Or just download from official template https://raw.githubusercontent.com/facebook/react-native/master/template/android/app/debug.keystore

或者直接从官方模板https://raw.githubusercontent.com/facebook/react-native/master/template/android/app/debug.keystore下载