这更像是一个一般的 java SSL 问题...
我正在使用 CXF 连接到安全网络服务。当我在我的本地 Windows 开发机器上运行它时,它可以连接并工作,但是,一旦我将它部署到我的应用程序服务器 (glassfish 3.1),它就不再工作了。我明白了:
Caused by: javax.net.ssl.SSLHandshakeException: SSLHandshakeException invoking https://vendorUrl: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1458)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1443)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:659)
我已经尝试将证书添加到 domain\config\cacerts.jks 文件、lib\security\cacerts 文件等,但是因为这个问题已经被问过很多次了,所以我不问为什么不这样做工作(虽然,我想知道为什么)。
让我感到困惑的是,为什么这可以在我的本地开发机器上运行而不向任何 keystore 添加任何内容?我的意思是,我没有通过浏览器连接到他们的 URL,我没有添加任何东西——它只是第一次从 Eclipse 开始工作。为什么?
最佳答案
What has me confused is, why would this work on my local dev machine without adding anything to any keystores? I mean, I didn't connect to their URL's via a browser, I didn't add anything - it just worked, the first time, from Eclipse.
您发布的信息没有帮助(这是我至少可以说的)。
你所说的只会在两种情况下发生:
1) 服务器使用已在 java 的信任库 cacert
中的受信任 CA 签名的证书(例如 Verisign)
2) 您已经启用了anonymous
密码套件
因为当您将它部署在不同的机器上时,您会遇到握手异常并提示验证,我想我们可以排除 (1)。
根据您的描述,(2) 似乎也是不可能的,因为您还没有启用匿名密码套件。
所以....请用更准确的信息更新您的帖子。还调试来自好的和坏的案例的信息
关于java - 服务器上的 SSL 不起作用,在本地计算机上工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10390131/