OkHttp SSLHandshakeException SSL handshake aborted Failure in SSL library, a protocol error

后端 未结 2 2099
抹茶落季
抹茶落季 2021-02-13 13:08
04-23 17:17:38.434 21599-21956/ D/NativeCrypto: ssl=0x0 NativeCrypto_SSL_interrupt
04-23 17:17:38.435 21599-21956/ D/OkHttp: <-- HTTP FAILED: javax.net.ssl.SSLHandsha         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-13 14:07

    So I solved it by adding the following to my http client object

     ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.COMPATIBLE_TLS)
                .tlsVersions(TlsVersion.TLS_1_2, TlsVersion.TLS_1_1, TlsVersion.TLS_1_0)
                .cipherSuites(
                        CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
                        CipherSuite.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
                        CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
                        CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA)
                .build();
    
    httpClient.connectionSpecs(Collections.singletonList(spec))
    

    reference : https://github.com/square/okhttp/issues/3894

提交回复
热议问题