• javax.net.ssl.sslhandshakeexception: pkix path building failed


    发送请求是跳过证书

    package com.yurun.micro.common.third.ding;
    
    import okhttp3.OkHttpClient;
    
    import javax.net.ssl.*;
    
    /**
     * okhttp ssl证书解决
     * @author dll
     * @create 2020-05-26
     */
    public class OkHttpSSL {
        public static OkHttpClient getUnsafeOkHttpClient() {
            try {
                final TrustManager[] trustAllCerts = new TrustManager[]{
                        new X509TrustManager() {
                            @Override
                            public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) {
                            }
    
                            @Override
                            public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) {
                            }
    
                            @Override
                            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                                return new java.security.cert.X509Certificate[]{};
                            }
                        }
                };
                final SSLContext sslContext = SSLContext.getInstance("SSL");
                sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
                final javax.net.ssl.SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
                OkHttpClient.Builder builder = new OkHttpClient.Builder();
                builder.sslSocketFactory(sslSocketFactory);
    
                builder.hostnameVerifier(new HostnameVerifier() {
                    @Override
                    public boolean verify(String hostname, SSLSession session) {
                        return true;
                    }
                });
                return builder.build();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }

    之后使用第三方jar时候又出现了了这个ssl问题 。切换了好几个版本号机缘巧合解决了问题,并没有解决实质性问题

    后来同事买了新电脑,发现没有这个问题。。。下定决心重装系统。。。完美解决了ssl证书问题和idea启动开2个小时左右,cpu飙升问题。。。。

  • 相关阅读:
    js类型自动转换以及==对比规则
    js改变作用域链
    cookie简单实例
    js操作cookie
    body设置margin为0
    inline-block和block元素水平居中显示
    执行git clone遇到警告解决办法
    git中各大写字母表示含义
    git命令报错
    linux.txt
  • 原文地址:https://www.cnblogs.com/donglulu/p/13384735.html
Copyright © 2020-2023  润新知