Sho*_*war 5 ssl https android android-4.4-kitkat
我正在使用REST api与ssl https上的服务器连接,问题是在android kitkat设备上。所有带有kitkat版本或4.xx版本的设备均未与服务器建立连接
javax.net.ssl.SSLException: Connection closed by peer at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
Run Code Online (Sandbox Code Playgroud)
在上述所有设备上,而不是4.xx都可以正常工作并建立连接
有什么解决方案吗?我也尝试过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()
}
}
Run Code Online (Sandbox Code Playgroud)
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
| 归档时间: |
|
| 查看次数: |
2981 次 |
| 最近记录: |