Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java apache httpclient使用https代理:对等未经身份验证_Java_Ssl_Proxy_Apache Httpclient 4.x - Fatal编程技术网

Java apache httpclient使用https代理:对等未经身份验证

Java apache httpclient使用https代理:对等未经身份验证,java,ssl,proxy,apache-httpclient-4.x,Java,Ssl,Proxy,Apache Httpclient 4.x,我正在尝试将hidemyas.com()上的免费https代理服务器列表中的一个用于ApacheHttpClient 4.1。我现在已经尝试了几乎所有的方法,但是我总是得到javax.net.ssl.SSLPeerUnverifiedException:peer未经身份验证 所以我在谷歌上搜索发现没有服务器有对等证书,例如: > openssl s_client -tls1 -showcerts -connect 109.75.178.230:3128 CONNECTED(000000

我正在尝试将hidemyas.com()上的免费https代理服务器列表中的一个用于ApacheHttpClient 4.1。我现在已经尝试了几乎所有的方法,但是我总是得到javax.net.ssl.SSLPeerUnverifiedException:peer未经身份验证 所以我在谷歌上搜索发现没有服务器有对等证书,例如:

> openssl s_client -tls1 -showcerts -connect 109.75.178.230:3128  
CONNECTED(00000003)
139856907785896:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:s3_pkt.c:337:

no peer certificate available

No client certificate CA names sent

SSL handshake has read 5 bytes and written 7 bytes

New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : 0000
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: 
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1393183549
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
当我尝试在同一个端口上切换到http时,它可以工作,但在Hidemyas上的代理列表中,类型是https。所以我不知道现在该怎么办。。。请帮忙


如果您需要查看我的代码:

因此,如果您没有问题,您可以信任以下所有证书

final TrustStrategy trustStrategy = new TrustStrategy() {

        @Override
        public boolean isTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
            return true;
        }
    };
    SSLContext sslcontext = null;
    try {
        sslcontext = SSLContexts.custom().loadTrustMaterial(null, trustStrategy).build();
    } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    socketFactory = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
然后使用

httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
这将确保所有https调用的证书都是可信的 但请确保只调用受信任的站点