android-android studio模拟器中的SSL问题,在手机上可以正常工作 [英] android - SSL problems in android studio emulator, works fine on phone

查看:149
本文介绍了android-android studio模拟器中的SSL问题,在手机上可以正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,可以通过https调用网络服务.当我在手机上运行apk时,效果很好.但是,在仿真器中,通过SSL进行的所有POST请求均失败,并显示以下信息:

I have an app which makes calls to a web service over https. When I run the apk on my phone, it works great. However, in the emulator, all of the POST requests over SSL fail with:

读取错误:ssl = 0xb402be00:SSL库失败,通常是协议错误 错误 错误:100c50bf:SSL例程:ssl3_read_bytes:NO_RENEGOTIATION(外部/无聊的sl/src/ssl/s3_pkt.c:852 0xabf7fcd7:0x00000000)

Read error: ssl=0xb402be00: Failure in SSL library, usually a protocol error error:100c50bf:SSL routines:ssl3_read_bytes:NO_RENEGOTIATION (external/boringssl/src/ssl/s3_pkt.c:852 0xabf7fcd7:0x00000000)

在我们服务器的访问日志中,每当模拟器尝试访问Web服务时,它都会报告403(禁止访问),这显然是因为模拟器没有 与我们的服务器正确握手. apache的错误日志中有一堆这样的行

In the access logs on our server, it reports a 403 (Forbidden) whenever the emulator tries to hit the webservice, apparantly because the emulator is not hand-shaking properly with our server. There a bunch of lines like this in apache's error log

[2015年8月20日星期四12:21:21] [错误] [客户端xxx.xxx.xxx.xxx] 重新协商握手失败:客户端不接受!!

[Thu Aug 20 12:21:21 2015] [error] [client xxx.xxx.xxx.xxx] Re-negotiation handshake failed: Not accepted by client!?

Apache实际上添加了!?"因此它看起来像是一个严重的意外错误.

Apache actually added the "!?" so it looks like a seriously unexpected error.

在我的IDE中,我已选中自动接受不受信任的证书" 的选项,但这没什么区别.

In my IDE, I have ticked the option for "Accept non-trusted certificates automatically" but that doesn't make a difference.

我已经在网上看到用于解决android中各种SSL问题的解决方案,但是,它们似乎都是手机本身存在的问题,需要修改代码.由于它可以在手机上正常工作,因此这似乎是Android Studio的问题,我应该可以使用配置设置来解决此问题.或者也许我必须在Apache中做些什么?

I have seen solutions on the web for fixing various SSL issues in android, however, they all seem to be the phone itself having an issue, and require code modification. Since it works fine on the phone, it seems like this is an Android Studio problem, and I should be able to correct this with a configuration setting. Or maybe I have to do something in a apache?

底线:如何让我的应用与Android Studio中的模拟器中的SSL网络服务进行通话?

使用Studio 1.3.1,Java 1.7.0_65,

Using Studio 1.3.1, Java 1.7.0_65,

compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
    applicationId "com.bla.bla"
    minSdkVersion 14
    targetSdkVersion 19
    multiDexEnabled true
    versionCode 12
    versionName '1.2.0.8'

推荐答案

我相信这是因为模拟器每次运行时都会重置您的CA证书.

I believe this is because the emulator will reset your CA Certificates each time it runs.

请注意,棉花糖中CA证书的位置已更改,我将尽快更新一些附加信息

Please be aware that the location of the CA Certs have changed in Marshmallow, I'll update with some additional information ASAP

这篇关于android-android studio模拟器中的SSL问题,在手机上可以正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆