gpt4 book ai didi

java - Cloudflare 免费 SSL ConnectException

转载 作者:太空宇宙 更新时间:2023-11-03 12:55:04 25 4
gpt4 key购买 nike

我已将我的网站置于 CloudFlare 之后,因为它具有免费的 SSL 功能。

在浏览器中一切正常。 SSL 锁在浏览器中正确显示。

但是如果我使用 Java 程序向同一个 Web 发出 HTTP GET 请求,我将得到异常。

以下是我写的小java程序。

package com.mycompany.textexception;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

public class Main {
public static void main(String [] args) throws IOException, URISyntaxException{
URI loginUri = new URI("https://site-behind-cf.in/");

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet( loginUri );
HttpResponse response = httpclient.execute( httpget );
System.out.println("Done");
}
}

异常(exception)的是

Exception in thread "main" java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:656)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:524)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:403)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at com.mycompany.textexception.Main.main(Main.java:26)

注意:如果我指向 https://www.google.co.inhttps://my-other-web.com,相同的程序将正常工作> 它不在 CloudFlare 之后,并且有自己的 SSL。

最佳答案

SSL 免费计划使用来自 Comodo 或 GlobalSign 的椭圆曲线数字签名算法 (ECDSA) 证书。

这些证书仅适用于支持服务器名称指示 (SNI) 的现代浏览器

如果你使用 Cloudflare Pro,你可能不会遇到同样的问题

关于java - Cloudflare 免费 SSL ConnectException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31583303/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com