Android 7.0 https/tls证书配置问题
2017-03-23 09:16
309 查看
最近系统更新到7.0后https/tls网络请求出现异常
原来Android 7.0以后google增加了网络配置,在https/tls只需要在配置文件中添加相应配置即可完成https协议的网络请求,对于由正式ca签名的证书不需要配置,主要针对自签名的证书。
第一步AndroidManifestw文件添加
第二步添加res/xml/network_security_config.xml:
以 PEM 或 DER 格式将自签署或非公共 CA 证书添加到 res/raw/my_cer。
在我的项目中采用的是ca的证书始终报java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.后来改为直接采用服务器证书终于通过,不知道是ca证书生成的有问题还是什么,但7.0以下通讯都正常。
SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
原来Android 7.0以后google增加了网络配置,在https/tls只需要在配置文件中添加相应配置即可完成https协议的网络请求,对于由正式ca签名的证书不需要配置,主要针对自签名的证书。
第一步AndroidManifestw文件添加
<?xml version="1.0" encoding="utf-8"?> <manifest ... > <application android:networkSecurityConfig="@xml/network_security_config" ... > ... </application> </manifest>
第二步添加res/xml/network_security_config.xml:
<?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config> <domain includeSubdomains="true">example.com</domain> <trust-anchors> <certificates src="@raw/my_cer"/> </trust-anchors> </domain-config> </network-security-config>
以 PEM 或 DER 格式将自签署或非公共 CA 证书添加到 res/raw/my_cer。
在我的项目中采用的是ca的证书始终报java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.后来改为直接采用服务器证书终于通过,不知道是ca证书生成的有问题还是什么,但7.0以下通讯都正常。
相关文章推荐
- Android手机进行无线EAP-TLS证书认证配置
- https 单向认证和双向认证及tomcat配置及各种证书类型之间的转换,适用ios,Android,网页端
- Android中进行https请求信任证书问题
- 解决IIS配置HTTPS证书完成证书后刷新后证书消失问题
- Docker Registry Server 搭建,配置免费HTTPS证书,及拥有权限认证、TLS 的私有仓库
- Android开发中关于Xwalkview加载https网页出现安全证书ssl问题
- Cordova下自签名证书无法访问https问题(IOS和Android)
- Android中进行https请求信任证书问题(效率解决,小白适用)
- tomcat 配置ssl/https 证书问题(一)- No enum constant org.apache.tomcat.util.net.SSLHostConfigCertificate.Typ
- Android 7.0解决抓取不到https请求的问题
- WebView加载https链接的安全校验问题【7.0手机验证证书无法加载出带证书https页面】
- TOMCAT配置HTTPS生成单向证书问题
- 关于android使用okhttpUtils使用请求https请求证书签名问题
- Android 7.0解决抓取不到https请求的问题
- https Android 5.0 以下TLS 版本过低造成的问题
- Docker Registry Server 搭建,配置免费HTTPS证书,及拥有权限认证、TLS 的私有仓库
- nginx配置https及Android客户端访问自签名证书
- Android https 证书信任问题