1

在服务器中禁用 http 端口后,我试图从 https 站点访问操作。它抛出以下错误。启用 http 后,它的工作正常。然后我可以使用 https 请求 .. 请在下面找到启用 sslConnection 的代码

public static void enableSSL() throws NoSuchAlgorithmException, KeyManagementException {
     TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {

            @Override
            public void checkClientTrusted(X509Certificate[] chain,
                    String authType) throws CertificateException {
                // TODO Auto-generated method stub

            }

            @Override
            public void checkServerTrusted(X509Certificate[] chain,
                    String authType) throws CertificateException {
                // TODO Auto-generated method stub

            }

            @Override
            public X509Certificate[] getAcceptedIssuers() {
                // TODO Auto-generated method stub
                return null;
            }



        } };
        // Install the all-trusting trust manager
        SSLContext sc = SSLContext.getInstance("SSL");
        // Create empty HostnameVerifier
        HostnameVerifier hv = new HostnameVerifier() {


            @Override
            public boolean verify(String arg0, SSLSession arg1) {
                // TODO Auto-generated method stub
                return true;
            }
        };

        sc.init(null, trustAllCerts, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
        HttpsURLConnection.setDefaultHostnameVerifier(hv);

}

请在下面找到错误

com.sun.xml.ws.client.ClientTransportException: HTTP transport error:
java.net.SocketTimeoutException: connect timed out at 
com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:132) at 
com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:153) at 
com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:94) at 
com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:116) at
com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598) at 
com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557) at
com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542) at 
com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439) at 
com.sun.xml.ws.client.Stub.process(Stub.java:222) at 
com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135) at 
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:109) at 
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89) at 
com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118) at 
$Proxy32.getStageRoot(Unknown Source) at 
com.hash.aif.client.file.AIFFilePortClient.getStageRoot(AIFFilePortClient.java:57) at 
com.hash.aif.client.AifSSLClient.main(AifSSLClient.java:21) Caused by:
java.net.SocketTimeoutException: connect timed out at 
java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at 
java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at 
java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at 
java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at 
java.net.AbstractPlainSocketImpl.connect(Unknown Source) at 
java.net.PlainSocketImpl.connect(Unknown Source) at 
java.net.SocksSocketImpl.connect(Unknown Source) at 
java.net.Socket.connect(Unknown Source) at 
sun.security.ssl.SSLSocketImpl.connect(Unknown Source) at 
sun.net.NetworkClient.doConnect(Unknown Source) at 
sun.net.www.http.HttpClient.openServer(Unknown Source) at 
sun.net.www.http.HttpClient.openServer(Unknown Source) at 
sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source) at 
sun.net.www.protocol.https.HttpsClient.New(Unknown Source) at 
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source) at 
sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at 
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source) at 
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source) at 
sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source) at 
com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:120) ... 15 more
4

1 回答 1

1

HTTPS 与标准 HTTP (80) 位于不同的端口 (443)。连接超时,因此很可能是服务器没有提供 HTTPS(它只提供 HTTP),或者有一些防火墙问题阻止您访问目标计算机上的端口 443。

这是指示连接超时的错误堆栈的相关部分:

Caused by:
java.net.SocketTimeoutException: connect timed out at 
java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at 
java.net.DualStackPlainSocketImpl.socketConnect(Unknown S
于 2012-06-10T04:39:29.617 回答