Websphere-SOAP服务-使用默认SSLSocketFactory

时间:2018-09-04 15:59:24

标签: java soap https websphere

我正在Websphere Application Server 8.5环境中工作,并且试图集成使用HTTPS协议公开的新Web服务。考虑到,第一次集成是使用HTTP协议调用服务完成的,因此,我修改了代码,以便使用SSL管理通信。在下面,您可以看到管理此服务连接的代码,但此刻在信任证书期间我收到错误消息。我已经检查过WAS TreustStore中是否安装了正确的证书。

代码:

    GenericResponse response = null;
    AdaptiveAuthentication service = new AdaptiveAuthentication();
    AdaptiveAuthenticationInterface serviceInterface = service.getAdaptiveAuthentication();
    BindingProvider bindingProvider = ((BindingProvider) serviceInterface);
    Map<String, Object> requestCtx = bindingProvider.getRequestContext();
    requestCtx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
    Client client = ClientProxy.getClient(serviceInterface);
    HTTPConduit http = (HTTPConduit) client.getConduit();
    TLSClientParameters tls_cp = new TLSClientParameters();
    SocketFactory sf = SSLSocketFactory.getDefault();
    if( sf instanceof SSLSocketFactory){
        tls_cp.setSSLSocketFactory((SSLSocketFactory) sf);
    }
    tls_cp.setUseHttpsURLConnectionDefaultSslSocketFactory(true);   
    tls_cp.setTrustManagers(getTrustAllTrustManager());
    tls_cp.setSecureRandom(new SecureRandom());
    tls_cp.setCipherSuites(Arrays.asList(((SSLSocketFactory) sf).getDefaultCipherSuites()));
    tls_cp.setJsseProvider((new com.ibm.security.jgss.IBMJGSSProvider()).getName());
    requestCtx.put(JAXWSProperties.SSL_SOCKET_FACTORY,tls_cp.getSSLSocketFactory());
    requestCtx.put(com.sun.xml.internal.ws.developer.JAXWSProperties.SSL_SOCKET_FACTORY, tls_cp.getSSLSocketFactory());
    http.setTlsClientParameters(tls_cp);
    if (type.equals(TMConstants.Type.ANALYZE)) {
        response = serviceInterface.analyze((AnalyzeRequest) request);
    } else if (type.equals(TMConstants.Type.NOTIFY)) {
        response = serviceInterface.notify((NotifyRequest) request);
    }

错误:

  

org.apache.cxf.binding.soap.SoapFault:将SAAJ模型写入流时出现问题       在org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor $ SAAJOutEndingInterceptor.handleMessage(SAAJOutInterceptor.java:221)〜[cxf-rt-bindings-soap-2.7.3.jar:2.7.3]       在org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor $ SAAJOutEndingInterceptor.handleMessage(SAAJOutInterceptor.java:172)〜[cxf-rt-bindings-soap-2.7.3.jar:2.7.3]       在org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)〜[cxf-api-2.7.3.jar:2.7.3]       在org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)[cxf-api-2.7.3.jar:2.7.3]       在org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)[cxf-api-2.7.3.jar:2.7.3]       在org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)[cxf-api-2.7.3.jar:2.7.3]       在org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)[cxf-api-2.7.3.jar:2.7.3]       在org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)[cxf-rt-frontend-simple-2.7.3.jar:2.7.3]       在org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)[cxf-rt-frontend-jaxws-2.7.3.jar:2.7.3]       在com.sun.proxy。$ Proxy1283.analyze(未知来源)[na:na]       在xx.xxxx.xframe.xxx.common.log.txmon.CallbackHandler.call(CallbackHandler.java:110)[XXX.jar:na]       在xx.xxxx.xframe.xxx.common.log.xxxx.CallbackHandler.call(CallbackHandler.java:33)[XXX.jar:na]       在java.util.concurrent.FutureTask.run(FutureTask.java:274)[na:1.7.0]       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1157)[na:1.7.0]       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:627)[na:1.7.0]       在java.lang.Thread.run(Thread.java:809)[na:1.7.0]   引起原因:com.ctc.wstx.exc.WstxIOException:com.ibm.jsse2.util.h:PKIX路径构建失败:java.security.cert.CertPathBuilderException:PKIXCertPathBuilderImpl无法构建有效的CertPath。内部原因是:       java.security.cert.CertPathValidatorException:由C​​N = ,O = 。,C = IT颁发的证书不受信任;内部原因是:       java.security.cert.CertPathValidatorException:证书链接错误       在com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:261)〜[woodstox-core-asl-4.1.4.jar:4.1.4]       在org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor $ SAAJOutEndingInterceptor.handleMessage(SAAJOutInterceptor.java:213)〜[cxf-rt-bindings-soap-2.7.3.jar:2.7.3]       ...省略了15个通用框架   原因:javax.net.ssl.SSLHandshakeException:com.ibm.jsse2.util.h:PKIX路径构建失败:java.security.cert.CertPathBuilderException:PKIXCertPathBuilderImpl无法构建有效的CertPath。内部原因是:       java.security.cert.CertPathValidatorException:由C​​N = ,O = ,C = IT颁发的证书不受信任;内部原因是:       java.security.cert.CertPathValidatorException:证书链接错误       在com.ibm.jsse2.k.a(k.java:24)〜[na:7.0 build_20170331]       在com.ibm.jsse2.rc.a(rc.java:19)〜[na:7.0 build_20170331]       在com.ibm.jsse2.bb.a(bb.java:308)〜[na:7.0 build_20170331]       在com.ibm.jsse2.bb.a(bb.java:338)〜[na:7.0 build_20170331]       在com.ibm.jsse2.cb.a(cb.java:558)〜[na:7.0 build_20170331]       在com.ibm.jsse2.cb.a(cb.java:187)〜[na:7.0 build_20170331]       在com.ibm.jsse2.bb.t(bb.java:537)〜[na:7.0 build_20170331]       在com.ibm.jsse2.bb.a(bb.java:530)〜[na:7.0 build_20170331]       在com.ibm.jsse2.rc.a(rc.java:797)〜[na:7.0 build_20170331]       在com.ibm.jsse2.rc.h(rc.java:710)〜[na:7.0 build_20170331]       在com.ibm.jsse2.rc.a(rc.java:815)〜[na:7.0 build_20170331]       在com.ibm.jsse2.rc.startHandshake(rc.java:408)〜[na:7.0 build_20170331]       在com.ibm.net.ssl.www2.protocol.https.c.afterConnect(c.java:142)〜[na:7.0 build_20170331]       在com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:4)〜[na:7.0 build_20170331]       在sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1146)〜[na:1.7.0]       在com.ibm.net.ssl.www2.protocol.https.b.getOutputStream(b.java:49)〜[na:7.0 build_20170331]       在org.apache.cxf.transport.http.URLConnectionHTTPConduit $ URLConnectionWrappedOutputStream.setupWrappedStream(URLConnectionHTTPConduit.java:170)〜[cxf-rt-transports-http-2.7.3.jar:2.7.3]       在org.apache.cxf.transport.http.HTTPConduit $ WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1282)〜[cxf-rt-transports-http-2.7.3.jar:2.7.3]       在org.apache.cxf.transport.http.HTTPConduit $ WrappedOutputStream.onFirstWrite(HTTPConduit.java:1233)〜[cxf-rt-transports-http-2.7.3.jar:2.7.3]       在org.apache.cxf.transport.http.URLConnectionHTTPConduit $ URLConnectionWrappedOutputStream.onFirstWrite(URLConnectionHTTPConduit.java:183)〜[cxf-rt-transports-http-2.7.3.jar:2.7.3]       在org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:47)〜[cxf-api-2.7.3.jar:2.7.3]       在org.apache.cxf.io.AbstractThresholdOutputStream.unBuffer(AbstractThresholdOutputStream.java:89)〜[cxf-api-2.7.3.jar:2.7.3]       在org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:63)〜[cxf-api-2.7.3.jar:2.7.3]       在com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:100)〜[woodstox-core-asl-4.1.4.jar:4.1.4]       在com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:225)〜[woodstox-core-asl-4.1.4.jar:4.1.4]       在com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:259)〜[woodstox-core-asl-4.1.4.jar:4.1.4]       ...省略了16个通用框架   导致原因:com.ibm.jsse2.util.h:PKIX路径构建失败:java.security.cert.CertPathBuilderException:PKIXCertPathBuilderImpl无法构建有效的CertPath。内部原因是:       java.security.cert.CertPathValidatorException:由C​​N = ,O = ,C = IT颁发的证书不受信任;内部原因是:       java.security.cert.CertPathValidatorException:证书链接错误       在com.ibm.jsse2.util.f.a(f.java:44)〜[na:7.0 build_20170331]       在com.ibm.jsse2.util.f.b(f.java:123)〜[na:7.0 build_20170331]       在com.ibm.jsse2.util.e.a(e.java:3)〜[na:7.0 build_20170331]       在com.ibm.jsse2.zc.a(zc.java:163)〜[na:7.0 build_20170331]       在com.ibm.jsse2.zc.a(zc.java:130)〜[na:7.0 build_20170331]       在com.ibm.jsse2.zc.checkServerTrusted(zc.java:40)〜[na:7.0 build_20170331]       在com.ibm.jsse2.cb.a(cb.java:453)〜[na:7.0 build_20170331]       ...省略了37个通用框架   原因:java.security.cert.CertPathBuilderException:PKIXCertPathBuilderImpl无法构建有效的CertPath。       在com.ibm.security.cert.PKIXCertPathBuilderImpl.engineBuild(PKIXCertPathBuilderImpl.java:410)〜[na:7.0 build_20170331]       在java.security.cert.CertPathBuilder.build(CertPathBuilder.java:256)〜[na:na]       在com.ibm.jsse2.util.f.a(f.java:99)〜[na:7.0 build_20170331]       ...省略了43个通用框架   引起原因:java.security.cert.CertPathValidatorException:由C​​N = ,O = ,C = IT颁发的证书不受信任       位于com.ibm.security.cert.BasicChecker。(BasicChecker.java:111)〜[na:7.0 build_20170331]       在com.ibm.security.cert.PKIXCertPathValidatorImpl.engineValidate(PKIXCertPathValidatorImpl.java:176)〜[na:7.0 build_20170331]       在com.ibm.security.cert.PKIXCertPathBuilderImpl.myValidator(PKIXCertPathBuilderImpl.java:737)〜[na:7.0 build_20170331]       com.ibm.security.cert.PKIXCertPathBuilderImpl.buildCertPath(PKIXCertPathBuilderImpl.java:649)〜[na:7.0 build_20170331]       在com.ibm.security.cert.PKIXCertPathBuilderImpl.buildCertPath(PKIXCertPathBuilderImpl.java:595)〜[na:7.0 build_20170331]       在com.ibm.security.cert.PKIXCertPathBuilderImpl.buildCertPath(PKIXCertPathBuilderImpl.java:595)〜[na:7.0 build_20170331]       在com.ibm.security.cert.PKIXCertPathBuilderImpl.engineBuild(PKIXCertPathBuilderImpl.java:356)〜[na:7.0 build_20170331]       ...省略了45个通用框架   引起原因:java.security.cert.CertPathValidatorException:证书链接错误       在com.ibm.security.cert.CertPathUtil.findIssuer(CertPathUtil.java:316)〜[na:7.0 build_20170331]       位于com.ibm.security.cert.BasicChecker。(BasicChecker.java:108)〜[na:7.0 build_20170331]       ...省略了51个常见框架

请帮助我了解我在做什么错... 预先感谢

0 个答案:

没有答案