2017-07-31 125 views
3

我使用REST API與SSL連接服務器https: problm是在android kitkat設備上。與奇巧版本或4.x.x所有設備都賺不到比4.x.x做工精細,使連接javax.net.ssl.SSLException:由對等關閉的連接。在Android kitkat版本

所有上述設備與服務器

javax.net.ssl.SSLException: Connection closed by peer at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) 

連接是否有任何解決方案。我也嘗試了OkHttp,這也不是我的原因。

回答

1

我之前遇到過類似的問題,我的終端使用TLS 1.2進行加密。如果您的終端正在使用https,則可以嘗試更改爲http以進行未加密的api調用。如果這是一個選項。

如果你只用Google Play Services釋放您的設備上的應用程序,你可以使用ProviderInstaller爲TLS 1.2

fun installSecurityProvider() { 
    try { 
     ProviderInstaller.installIfNeeded(activity) 
    } catch (e: GooglePlayServicesRepairableException) { 
     handlePlayServicesError(e.connectionStatusCode) 
    } catch (e: GooglePlayServicesNotAvailableException) { 
     handleCriticalFailure() 
    } 
} 
提供支持

https://developer.android.com/training/articles/security-gms-provider.html

存在這樣的問題,其討論這個okhttp git的一個頁面中打開問題。

https://github.com/square/okhttp/issues/3098

如果依靠播放服務是不是自己實現一個選項,然後它的可能。

https://github.com/square/okhttp/issues/2372#issuecomment-244807676

相關問題