zoukankan      html  css  js  c++  java
  • 创建ssl类型的client

    public static CloseableHttpClient wrapClient() {
            try {
                SSLContext ctx = SSLContext.getInstance("TLS");
                X509TrustManager tm = new X509TrustManager() {
                    public X509Certificate[] getAcceptedIssuers() {
                        return null;
                    }
                    public void checkClientTrusted(X509Certificate[] arg0,
                                                   String arg1) throws CertificateException {
                    }
    
                    public void checkServerTrusted(X509Certificate[] arg0,
                                                   String arg1) throws CertificateException {
                    }
                };
                ctx.init(null, new TrustManager[] { tm }, null);
                SSLConnectionSocketFactory ssf = new SSLConnectionSocketFactory(
                        ctx, NoopHostnameVerifier.INSTANCE);
                CloseableHttpClient httpclient = HttpClients.custom()
                        .setSSLSocketFactory(ssf).build();
                return httpclient;
            } catch (Exception e) {
                return HttpClients.createDefault();
            }
        }
    

      

  • 相关阅读:
    UDP
    ICMP协议、DNS、ARP协议、ping、DHCP协议
    OSI七层模型和TCP/IP四层模型
    STL六大组件
    迭代器
    哈希表
    react wangeditor使用
    URL切割
    ES6对象合并
    nginx 访问本机文件
  • 原文地址:https://www.cnblogs.com/xiaowei89426/p/9365041.html
Copyright © 2011-2022 走看看