javax.net.ssl.SSLException:由对等关闭的连接。在Android kitkat版本
问题描述:
我使用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,这也不是我的原因。
答
我之前遇到过类似的问题,我的终端使用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