Tomcat 和 SSL:密钥库格式无效
启动 Tomcat 6 时遇到以下问题:
[INFO] [talledLocalContainer] Caused by: java.io.IOException: Invalid keystore format
[INFO] [talledLocalContainer] at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:633)
[INFO] [talledLocalContainer] at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:38)
[INFO] [talledLocalContainer] at java.security.KeyStore.load(KeyStore.java:1185)
[INFO] [talledLocalContainer] at org.springframework.ws.soap.security.support.KeyStoreFactoryBean.afterPropertiesSet(KeyStoreFactoryBean.java:123)
我已将 KeyStoreFactoryBean 配置为在我的类路径中加载密钥库,这是我自己使用 java 1.6.0_05 创建的。
奇怪的是,当我使用 Eclipse 启动同一个 Tomcat 时,密钥库加载时没有任何问题。如果我使用 Cargo Maven 插件启动 Tomcat,则会出现此异常。如果我在新下载的 Tomcat 6 中安装该应用程序,则会出现异常。不幸的是,在我们的 UNIX 环境中部署应用程序时,我遇到了同样的异常。
我安装的唯一jdk版本是1.6.0_05和1.6.0_23,但是我已经尝试过这两个版本,但似乎没有什么区别。我也在另一台只有 1.6.0_05 的机器上尝试过,也不起作用。 一位同事在他的应用程序中使用相同的密钥库,没有任何问题,并且他的 Spring 配置完全相同(但不要认为问题出在此处)。
查看 JavaKeyStore 的源代码时(源代码)您可以看到它检查从密钥库读取的前两个整数以检查其格式并引发异常。我无法想象使用 Eclipse 启动 Tomcat 有何不同可能会导致这段代码以其他方式执行而不抛出异常。
谷歌搜索也没有帮助我,很多人似乎都遇到了这个例外,但通常是因为他们使用旧版本的 jdk 制作了密钥库。
编辑:提供程序是“SUN version 1.6”,类型是JKS。这对于工作和不工作这两种情况都是一样的。
I'm having the following problem when starting Tomcat 6:
[INFO] [talledLocalContainer] Caused by: java.io.IOException: Invalid keystore format
[INFO] [talledLocalContainer] at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:633)
[INFO] [talledLocalContainer] at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:38)
[INFO] [talledLocalContainer] at java.security.KeyStore.load(KeyStore.java:1185)
[INFO] [talledLocalContainer] at org.springframework.ws.soap.security.support.KeyStoreFactoryBean.afterPropertiesSet(KeyStoreFactoryBean.java:123)
I have configured the KeyStoreFactoryBean to load a keystore in my classpath, which I made myself using java 1.6.0_05.
The weird thing is, when I start the same Tomcat using Eclipse the keystore gets loaded without any problems. If I start the Tomcat using the Cargo Maven plugin, I get this exception. If I install the application in a freshly downloaded Tomcat 6 I get the excetpion. And unfortunately I get the same exception when deploying the application on our unix environments.
The only jdk versions I have installed are 1.6.0_05 and 1.6.0_23, however I've tried with both versions and it doesn't seem to make difference. I've also tried it on a different machine with only 1.6.0_05, didn't work either.
A colleague who uses the same keystore in his applications has no problems whatsoever, and his Spring configuration is exactly the same (don't think the problem lies there though).
When looking in the source of JavaKeyStore (source code) you can see it checks the first two ints it reads from the keystore to check it's format and throw the exception. I can't image what difference in starting Tomcat using Eclipse may cause this piece of code to execute otherwise and not throw the exception.
Googling didn't help me either, lots of people seem to get this exception, but usually because they made the keystore with an older version of the jdk.
Edit: the provider is "SUN version 1.6" and type is JKS. This the same for both cases, working and not-working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决:maven 构建过滤了证书(使用资源插件)并以某种方式更改了密钥库。从资源插件中排除密钥库解决了这个问题。
Solved: the maven build filtered the certificate (using the resources plugin) and somehow changed the keystore. Excluding the keystore from the resources plugin solved it.