80,349
社区成员
发帖
与我相关
我的任务
分享
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;
}
* https三次握手:
* 客户端发送 TLS版本号 加密套件(这里) 随机数 hello
* 服务端根据客户端发送的加密套件、TLS版本号 选择对应的加密协议及套件 把加密协议、加密套件、随机数、服务端证书、hello发送给客户端
* 客户端收到信息后 生成随机数(通过公钥进行加密) 编码结速通知 握手结束通知
* 服务端 通过私钥解密 编码改变通知 握手结束通知
* 对称加密数据传输