如何使用 Retrofit 添加 TLS v 1.0 和 TLS v.1.1 [英] How to add TLS v 1.0 and TLS v.1.1 with Retrofit

查看:55
本文介绍了如何使用 Retrofit 添加 TLS v 1.0 和 TLS v.1.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用改造进行数据传输,但几天前我遇到了 ssl 证书问题:

I am using retrofit for data transfer, but few days ago i got problem with ssl certificates:

SSL 握手在系统调用期间中止了 ssl=0x7b93fcc0 错误.对端重置连接

SSL handshake aborted ssl=0x7b93fcc0 error during system call. Connection reset by peer

据我所知,我需要在改造中添加 tlsv1 证书...

as I understand I need to add tlsv1 certificate inside retrofit...

有什么建议怎么做吗?

推荐答案

如果你使用 OkHttp 客户端进行 Retrofit,你应该像这里一样设置密码套件,只需更改 TLS 版本并适合你的连接类型:

If you are using OkHttp client for Retrofit, you should set up cipher suites like here, just change the TLS version and suits accordingly to your connection type:

ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)  
.tlsVersions(TlsVersion.TLS_1_2)
.cipherSuites(
      CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
      CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
      CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256)
.build();

Square 的 OkHttp wiki 的更多详情

这篇关于如何使用 Retrofit 添加 TLS v 1.0 和 TLS v.1.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆