简体   繁体   English

Android:okhttp3>崩溃:意外的TLS版本:NONE

[英]Android: okhttp3 > crash: Unexpected TLS version: NONE

I've integrated retrofit2 since couple of months ago; 从几个月前开始,我就集成了retrofit2 there were no problem until yesterday with an user (Huawei, model MHA-L29, on Android 7.0): 直到昨天,用户才有问题(华为,型号MHA-L29,在Android 7.0上):

Fatal Exception: java.lang.IllegalArgumentException: Unexpected TLS version: NONE
       at okhttp3.TlsVersion.forJavaName(TlsVersion.java:53)
       at okhttp3.Handshake.get(Handshake.java:56)
       at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:300)
       at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:268)
       at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:160)
       at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)
       at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134)
       at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)
       at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
       at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
       at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
       at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
       at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
       at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147)
       at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:776)

In my Gradle : 在我的Gradle

implementation 'com.squareup.retrofit2:retrofit:2.3.0' 实施'com.squareup.retrofit2:retrofit:2.3.0'

Have you got some ideas about this crash? 您对这次车祸有一些想法吗? Is there a link with Retrofit ? 是否与Retrofit有链接? I didn't add OkHttp library in my Gradle , I must do it? 我没有在Gradle添加OkHttp library ,我必须这样做吗?

Can you try this by providing TLS configuration I am not sure if this will work. 您可以通过提供TLS配置来尝试吗?我不确定是否可以使用。 referred from here 这里引用

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();

OkHttpClient client = new OkHttpClient.Builder()
        .connectionSpecs(Collections.singletonList(spec))
        .build();

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(BASE_URL)
        .client(client)
        .build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM