我使用=>>处给出的示例http://metro.java.net/nonav/1.2/guide/Example_Applications.html#ahies 尝试使用jdk 7和glassfish 4.0在netbeans 7.3.1中通过SSL进行saml身份验证。 但是,当我运行我的客户端代码时,我得到了一个异常
例外
javax.xml.ws.WebServiceException)javax.xml.ws.WebServiceException:无法访问WSDL:https://:8181 / CalculatorApplication / CalculatorWS?wsdl。它失败了: java.security.cert.CertificateException:找不到名称匹配。
当我尝试创建服务时,我的JSP出现了异常:
org.me.calculator.client.CalculatorWS_Service service = new org.me.calculator.client.CalculatorWS_Service();
任何试过这个或遇到类似问题的人都可以帮我解决这个问题。
完成堆栈跟踪=>
SEVERE:javax.xml.ws.WebServiceException:无法访问WSDL:https://:8181 / CalculatorApplication / CalculatorWS?wsdl。它失败了: java.security.cert.CertificateException:找不到名称匹配。 at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:249) 在com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:230) at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:193) at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:162) 在com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:359) 在com.sun.xml.ws.client.WSServiceDelegate。(WSServiceDelegate.java:321) 在com.sun.xml.ws.client.WSServiceDelegate。(WSServiceDelegate.java:230) 在com.sun.xml.ws.client.WSServiceDelegate。(WSServiceDelegate.java:212) 在com.sun.xml.ws.client.WSServiceDelegate。(WSServiceDelegate.java:208) at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:112) 在javax.xml.ws.Service。(Service.java:92) 在org.me.calculator.client.CalculatorWS_Service。(CalculatorWS_Service.java:42) 在org.apache.jsp.index_jsp._jspService(index_jsp.java:58) 在org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473) 在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 在org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 在org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 在com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 在org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260) 在com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188) 在org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) 在org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) 在org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) 在org.glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114) 在org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 在org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838) 在org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) 在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) 在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100(WorkerThreadIOStrategy.java:55) 在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) 在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:564) 在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:544) 在java.lang.Thread.run(Thread.java:724) 引起:javax.net.ssl.SSLHandshakeException:java.security.cert.CertificateException:找不到名称匹配 at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884) 在sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276) 在sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341) at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868) 在sun.security.ssl.Handshaker.process_record(Handshaker.java:804) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323) 在sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) 在java.net.URL.openStream(URL.java:1037) at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:983) at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:384) 在com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:215) ......还有44个 引起:java.security.cert.CertificateException:找不到名称匹配 at sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:208) at sun.security.util.HostnameChecker.match(HostnameChecker.java:93) at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:347) at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:203) at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323) ... 59更多
答案 0 :(得分:0)
这里有一个解决方案[1]。看起来这是一个已知问题。我没有尝试过他提出的解决方案,但看起来问题是验证主机名。他正在覆盖验证方法。
public boolean verify(String hostname,
javax.net.ssl.SSLSession sslSession) {
if (hostname.equals("localhost")) {
return true;
}
return false;
}