OkHttpClient okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
.writeTimeout(15, TimeUnit.SECONDS)
.addNetworkInterceptor(new StethoInterceptor())
.followSslRedirects(true)
.connectionSpecs(Collections.singletonList(getConnectionSpec()))
.build(); private static ConnectionSpec getConnectionSpec() {
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
                            .tlsVersions(TlsVersion.TLS_1_0)
                            .cipherSuites(CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA256,
                                    CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA,
                                    CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA256,
                                    CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA,
                                    CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA)
                            .build();
return spec;
}

  

 

如果出现握手失败 ,出现日志信息为

10-17 11:41:32.771: W/System.err(32764): javax.net.ssl.SSLHandshakeException: Handshake failed
10-17 11:41:32.771: W/System.err(32764): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:441)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:241)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:198)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.connection.RealConnection.buildConnection(RealConnection.java:174)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:114)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:193)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
10-17 11:41:32.771: W/System.err(32764): at com.lzy.okgo.interceptor.LoggerInterceptor.intercept(LoggerInterceptor.java:40)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.RealCall.access$100(RealCall.java:33)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.RealCall$AsyncCall.execute(RealCall.java:120)
10-17 11:41:32.771: W/System.err(32764): at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
10-17 11:41:32.771: W/System.err(32764): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
10-17 11:41:32.771: W/System.err(32764): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
10-17 11:41:32.771: W/System.err(32764): at java.lang.Thread.run(Thread.java:818)
10-17 11:41:32.771: W/System.err(32764): Suppressed: javax.net.ssl.SSLHandshakeException: Handshake failed
10-17 11:41:32.771: W/System.err(32764): ... 29 more
10-17 11:41:32.771: W/System.err(32764): Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xeec2db00: Failure in SSL library, usually a protocol error
10-17 11:41:32.771: W/System.err(32764): error:100c1069:SSL routines:ssl3_get_server_key_exchange:BAD_DH_P_LENGTH (external/boringssl/src/ssl/s3_clnt.c:1244 0xee6cb7d7:0x00000000)
10-17 11:41:32.771: W/System.err(32764): at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
10-17 11:41:32.771: W/System.err(32764): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:353)
10-17 11:41:32.771: W/System.err(32764): ... 28 more
10-17 11:41:32.771: W/System.err(32764): Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xeec2db00: Failure in SSL library, usually a protocol error
10-17 11:41:32.771: W/System.err(32764): error:100c1069:SSL routines:ssl3_get_server_key_exchange:BAD_DH_P_LENGTH (external/boringssl/src/ssl/s3_clnt.c:1244 0xee6cb7d7:0x00000000)
10-17 11:41:32.771: W/System.err(32764): at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
10-17 11:41:32.771: W/System.err(32764): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:353)
10-17 11:41:32.771: W/System.err(32764): ... 28 more

可以修改客户端的  加密套件配置  能够解决此问题

* https三次握手:
     * 客户端发送 TLS版本号 加密套件(这里) 随机数 hello
     * 服务端根据客户端发送的加密套件、TLS版本号 选择对应的加密协议及套件 把加密协议、加密套件、随机数、服务端证书、hello发送给客户端
     * 客户端收到信息后 生成随机数(通过公钥进行加密) 编码结速通知 握手结束通知
     * 服务端 通过私钥解密 编码改变通知 握手结束通知
     * 对称加密数据传输

https握手失败案例(一)的更多相关文章

  1. 记一次https访问握手失败(handshake failure)

    文章作者:luxianghao 文章来源:http://www.cnblogs.com/luxianghao/p/6239518.html  转载请注明,谢谢合作. 免责声明:文章内容仅代表个人观点, ...

  2. 加密解密(4)SSL协议及HTTPS握手过程

    SSL协议 简介 SSL (Secure Sockets Layer 安全套接层)是一个安全协议,它提供使用 TCP/IP 的通信应用程序间的隐私与完整性.因特网的 超文本传输协议 (HTTP)使用 ...

  3. shell练习--PAT试题1010:一元多项式求导 (25 分)(失败案例喜加一)

    ---恢复内容开始--- 1010 一元多项式求导 (25 分) 设计函数求一元多项式的导数.(注:x​n​​(n为整数)的一阶导数为nx​n−1​​.) 输入格式: 以指数递降方式输入多项式非零项系 ...

  4. MacOS升级到Monterey后python SSL握手失败问题

    MacOS升级到Monterey 12.0.1后,忽然发现原来工作正常的python3请求华为restconf API报错失败,提示 ssl.SSLError: [SSL: SSLV3_ALERT_H ...

  5. HTTPS 握手过程理解

    转自https://www.jianshu.com/p/a3a25c6627ee https://blog.csdn.net/xingtian713/article/details/11953057 ...

  6. YourSQLDba备份失败案例锦集

    使用YourSQLDba做备份.维护.管理时,偶尔会收到一些备份失败的邮件.导致YourSQLDba备份失败的情况比价多,打算在此篇中对YourSQLDba备份失败的案例做一些总结.整理. 1:You ...

  7. HTTP与HTTPS握手的那些事

    今天我总结了什么是HTTP三次握手,还有HTTPS握手的过程以及为什么HTTPS是安全的. 前提 在讲述这两个握手时候,有一些东西需要提前说明. HTTP与TCP/IP区别? TPC/IP协议是传输层 ...

  8. Https握手协议以及证书认证

    1. 什么是https Https = http + 加密 + 认证 https是对http的安全强化,在http的基础上引入了加密和认证过程.通过加密和认证构建一条安全的传输通道.所以https可以 ...

  9. RF失败案例重跑

    1.1        失败案例重跑 该功能主要是针对上次连跑失败的案例需要重新执行测试的情况,可自动识别上次执行失败的案例并进行重跑,无需手动选择相应的案例,简单高效. 1.5.1.        重 ...

随机推荐

  1. HTTP上传大文件要考虑的问题

    1.大文件上传服务器内存占用 一般WEB开发框架如SpringMVC,在基于Web容器如Tomcat处理HTTP请求时,都倾向于采用职责链流水线式的处理机制.HTTP请求被封装为一个可解析对象放在内存 ...

  2. MSTAR GUI

    1.架构 WIN32 SDK ACT->CTL->API->GE/GOP ACT: Customized logic parts CTL: Behavior widgets API: ...

  3. Maven下org.junit.Test无法使用

    原文地址: https://blog.csdn.net/allenChenZhiMing/article/details/81412983 我在看Spring in action(第四版)的时候,看到 ...

  4. tomcat 的一些知识

    常见web服务器 1. WebLogic 支持J2EE规范2. WebSphere 支持J2EE3. Tomcat 支持JSP,servlet规范 需要配置JDK才能运行 tomcat JAVA_HO ...

  5. 双重检查锁实现单例(java)

    单例类在Java开发者中非常常用,但是它给初级开发者们造成了很多挑战.他们所面对的其中一个关键挑战是,怎样确保单例类的行为是单例?也就是说,无论任何原因,如何防止单例类有多个实例.在整个应用生命周期中 ...

  6. fullpage中高度错误的解决方法

    今天我再用fullpage写全屏页面的时候,发现在ie中,一整屏的页面总是不能铺满,高度总是少一截儿,各种搜索,找到了个合适的方法,这里记录下,也希望给之后遇到这个问题的人提供一种方式,当然不一定能解 ...

  7. 二Java的常量与变量-1-1标识符

    类的名字就是标识符 起类名也是不能带空格的

  8. PHP之操作数组

    https://www.jb51.net/Special/623.htm https://www.php.net/manual/zh/ref.array.php https://www.runoob. ...

  9. bzoj 2406: 矩阵【二分+有源汇上下界可行流】

    最大值最小,所以考虑二分 |Σaij-Σbij|<=mid,所以Σbij的上下界就是(Σaij-mid,Σaij+mid) 考虑建有上下界网络,连接(s,i,Σaik-mid,Σaik+mid) ...

  10. Python学习 Part2:深入Python函数定义

    在Python中,可以定义包含若干参数的函数,这里有几种可用的形式,也可以混合使用: 1. 默认参数 最常用的一种形式是为一个或多个参数指定默认值. >>> def ask_ok(p ...