java - 如何解决无法在生产环境中找到请求目标的有效认证路径?

标签 java tomcat ssl

我有一个 JKS,我需要它进行身份验证才能开始使用 SOAP 网络服务。 在我的本地机器(Windows)上一切正常。在 Eclipse 中将以下内容添加到我的 Tomcat 启动参数中:

-Dsun.security.ssl.allowUnsafeRenegotiation=true -Djavax.net.ssl.keyStore="path\to\keystore\keystore.jks"   -Djavax.net.ssl.keyStorePassword=passwordC -Djavax.net.ssl.keyStoreType=jks

在生产环境 (ubuntu) 中,我们有以下内容:

-Dsun.security.ssl.allowUnsafeRenegotiation=true -Djavax.net.ssl.keyStore=/path/to/keystore/keystore.jks -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.keyStoreType=jks"

我正在使用 Java 1.7.0.80 和 Tomcat 7.0.61

当我想连接 SOAP 网络服务时,我得到以下 Stacktrace:

Caused by: javax.net.ssl.SSLHandshakeException: SSLHandshakeException invoking https://www.correosexpress.com/wsp/services/GrabacionEnvio: 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:526)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1359)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1343)
    at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:56)
    at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:215)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:652)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    ... 121 more
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

我检查了 Java 版本,tomcat 版本。 我还检查了 JKS 的路径是否正确,确实如此。

在我的本地机器上,我没有手动安装任何其他证书。即我在 cacerts 中没有任何与 jks 中的内容相关的条目。

最佳答案

  1. 使用 java keytool 检查您的证书是否存在于证书列表中。
  2. 检查你的 java home 和你的 jre 是否相同。在 ubuntu 中,可以有一个 java 版本的 java_home 和其他版本的默认 jre(检查这个命令 - update-alternatives --config java)
  3. 如果您将证书添加到正确版本的 java 并且它出现在证书列表中,请检查您使用的证书版本是否正确。

关于java - 如何解决无法在生产环境中找到请求目标的有效认证路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36644503/

相关文章:

asp.net - 你如何将http请求转发到https url

java - 环境变量 DHIS2_HOME : null (TrayApp. java [main])

java - Spring boot中如何获取请求的url

java - 基本的 Java IO,总是抛出异常

java.net.绑定(bind)异常 : RMI port already in use Error

java - 在 tomcat 应用程序中更改我的应用程序的 web.xml 的位置

java - 如何使用 Jsoup 找到与某个单词匹配的所有 anchor ?

java - 为什么在 applicationContext.xml 中不接受 tomcat 的 -D 参数?

c# - 在 C# 中具有授权的 HTTPS 客户端

ssl - centos6/letsencrypt - wget 证书错误,但 curl 没有