Android问题记录03_javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handsh...

  • 问题记录

在Android 4.4的机器上https网络请求失败,但是测试时用Android4.4以上的手机一直没有发现这个问题,特此记录下这个问题

  • 现象

网络请求失败报错:
javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x78317148: Failure in SSL library, usually a protocol error error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:744 0x74017f64:0x00000000)

Glide加载图片也出错:


image.png
Protocol Supported (API Levels) Enabled by default (API Levels)
SSLv3 1–25 1–22
TLSv1 1+ 1+
TLSv1.1 16+ 20+
TLSv1.2 16+ 20+

可以看出虽然Android 16就虽然已经支持了TLS1.1和TLS1.,但是默认并没有开启,API 20才默认开启

因为项目是放谷歌playStore的 所以采取的解决办法是:
项目build.gradle文件中添加
dependencies {
....
implementation 'com.google.android.gms:play-services-auth:16.0.1'
}

Application中添加
try{
ProviderInstaller.installIfNeeded(this);
} catch (GooglePlayServicesRepairableException e) {

} catch (GooglePlayServicesNotAvailableException e) {
}

一定要try catch

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容