我在客户端使用Spring REST模板来调用REST端点。在这种情况下,客户端是Spring应用程序,Tomcat是servlet容器。为什么找不到SSL握手的信任库?
我遇到了连接到HTTPS端点的问题。我收到一个错误,指出它找不到信任库的有效路径。我可以在哪里指定?这是在容器级还是应用程序配置(Spring)级完成的?
堆栈跟踪:
org.springframework.web.client.ResourceAccessException: I/O error:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target;
nested exception is 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
org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:330)
org.springframework.web.client.RestTemplate.execute(RestTemplate.java:292)
org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:227)
在哪里写代码? – kamaci 2011-11-11 12:26:45
你可以在任何你喜欢的地方写下它,因为它在SSLContext类本身上进行静态调用。只要你在相同的类加载器上下文中调用它,并且在第一个HttpClient调用之前,那么你应该很好。 – 2011-12-06 15:47:57
可以肯定的是:如上所述更改SSLContext的TrustManager不是一个持久行为,对吧?所以每次启动应用程序时都需要完成。 – ptikobj 2014-03-27 08:30:48