問題描述
如何使用 Retrofit 添加 TLS v 1.0 和 TLS v.1.1 (How to add TLS v 1.0 and TLS v.1.1 with Retrofit)
我正在使用改造進行數據傳輸,但幾天前我遇到了 ssl 證書問題:
SSL 握手中止 ssl=0x7b93fcc0 在系統調用期間出現錯誤。對等方重置連接
據我了解,我需要在改造中添加tlsv1證書...
有什麼建議嗎?
參考解法
方法 1:
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();
more details on Square's OkHttp wiki
(by Stan Malcolm、cleanOK)