我正在尝试制作https soap请求但是我收到此错误:
Caused by: javax.net.ssl.SSLHandshakeException: SSLHandshakeException invoking *** : 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:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
问题是当我使用系统属性时:
System.setProperty("javax.net.ssl.trustStore", certPath);
System.setProperty("javax.net.ssl.trustStorePassword", certPasswd);
我没有收到错误,但是当我尝试手动加载信任存储时,它似乎不起作用:
TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore trustStore = KeyStore.getInstance("JKS");
trustStore.load(new FileInputStream(certPath), certPasswd.toCharArray());
tmFactory.init(trustStore);
SSLContext sslContext = SSLContext.getInstance("SSLv3");
sslContext.init(null , tmFactory.getTrustManagers(), null);
bp.getRequestContext().put(JAXWSProperties.SSL_SOCKET_FACTORY, sslContext.getSocketFactory());
我得到了上面提到的例外,关于如何解决它的任何想法?