gpt4 book ai didi

Android 7.0 : 'javax.net.ssl.SSLHandshakeException: Connection closed by peer

转载 作者:搜寻专家 更新时间:2023-11-01 08:27:16 25 4
gpt4 key购买 nike

当我尝试从我的应用程序访问“https”网络服务时,出现“javax.net.ssl.SSLHandshakeException: Connection closed by peer”错误。相同的 Web 服务在 Chrome 浏览器中运行良好。

此问题仅在 Android 7.0 上发生,在 Android 6.0 和 5.0 上正常。

服务器是 CA 认证的,不是自签名的。

最佳答案

尝试使用这段代码,它对我有用:

 private static void initializeSSLContext(Context mContext){
try {
SSLContext.getInstance("TLSv1.2");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
try {
ProviderInstaller.installIfNeeded(mContext.getApplicationContext());
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}

并且不要忘记使用谷歌安全库:

  compile 'com.google.android.gms:play-services-safetynet:11.6.2'

关于Android 7.0 : 'javax.net.ssl.SSLHandshakeException: Connection closed by peer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43617167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com