简体   繁体   English

无法从我的Android模拟器访问HTTPS

[英]Can't access HTTPS from my Android Emulator

I'm behind a corporate proxy and everything that access the internet needs a special configuration regarding Proxy. 我是公司代理的后面,访问互联网的一切都需要有关代理的特殊配置。 I'm on a CentOS 7, using CNTLMD to handle proxy tunneling, developing for mobile with React Native. 我在CentOS 7上,使用CNTLMD处理代理隧道,使用React Native开发移动设备。 And I'm using the Android Emulator provided by Android Studio. 我正在使用Android Studio提供的Android模拟器。

I first noticed that my emulator can't access any HTTPS protocol when I tried to open Google in the Browser. 我首先注意到,当我尝试在浏览器中打开Goog​​le时,我的模拟器无法访问任何HTTPS协议。 Internally google redirects to HTTPS and I always get that "Connection Refused" error. 内部谷歌重定向到HTTPS,我总是得到“拒绝连接”错误。 Later (this week), trying to use Axios and Fetch to make HTTP/HTTPS requests, this has become a serious problem, since the APIs I'm trying to connect to are under the HTTPS protocol. 稍后(本周),尝试使用Axios和Fetch来发出HTTP / HTTPS请求,这已经成为一个严重的问题,因为我尝试连接的API是在HTTPS协议下。

A friend of mine who is working in the same project but using Mac has no problems with HTTPS. 我的一个朋友在同一个项目中工作但使用Mac并没有使用HTTPS的问题。 I have also tried to start the emulator with the following commands: 我还尝试使用以下命令启动模拟器:

emulator -avd myemulator -http-proxy http://127.0.0.1:3128

And

emulator -avd Marshmallow86 -http-proxy http://<network username>:<network password>@<ip>:<port>

And they do nothing. 他们什么都不做。

I tried setting up HTTP and HTTPS proxy on Android Studio but this don't seem to be the way (and also didn't work). 我尝试在Android Studio上设置HTTP和HTTPS代理,但这似乎不是那种方式(也没有用)。

@edit @编辑

I set the http_proxy on my host and started the emulator without parameters. 我在我的主机上设置了http_proxy并启动了没有参数的模拟器。 Didn't work as well. 没有工作。

What am I missing? 我错过了什么?

I haven't used the software above that isn't android avd or androidstudio, but it looks like a proxy or CA certificate problem. 我没有使用上面的软件,不是android avd或androidstudio,但它看起来像代理或CA证书问题。 Since the difference seems to be by OS, I would guess CA certificate first. 由于差异似乎是由操作系统,我会首先猜测CA证书。

This android page has advice on using openssl from the command line to explore that and consider importing certificates. 这个android页面提供了从命令行使用openssl来探索它并考虑导入证书的建议。

https://developer.android.com/training/articles/security-config.html https://developer.android.com/training/articles/security-config.html

This android page has current suggestions for proxy configurations: https://developer.android.com/studio/run/emulator-networking.html 这个android页面有当前的代理配置建议: https//developer.android.com/studio/run/emulator-networking.html

Note, that the above instructions are updated for new features. 请注意,上述说明已针对新功能进行了更新。 In the past I needed a proxy to a non-ssl appengine development server which is slightly different from your problem but here's what I used: 在过去,我需要一个非ssl appengine开发服务器的代理,这与你的问题略有不同,但这是我使用的:

For an SSL proxy, used the apache web server, and configured it to use SSL by installing a self-signed certificate, then added a ProxyPass and ProxyPassReverse in httpd.conf and a ProxyPass in the httpd-ssl.conf. 对于SSL代理,使用apache Web服务器,并通过安装自签名证书将其配置为使用SSL,然后在httpd.conf中添加ProxyPass和ProxyPassReverse,在httpd-ssl.conf中添加ProxyPass。 ProxyPass / http://127.0.0.1:8080/ ProxyPass / http://127.0.0.1:8080/

Apache as an SSL proxy receives connections to https://127.0.0.1:443 and passes them to http://127.0.0.1:8080 作为SSL代理的Apache接收到https://127.0.0.1:443的连接并将它们传递给http://127.0.0.1:8080

Then in the application, code that will be running in the emulator can use address 10.0.2.2 to use android subnet routing table to connect to the dev. 然后在应用程序中,将在模拟器中运行的代码可以使用地址10.0.2.2使用android子网路由表连接到dev。 OS localhost. OS localhost。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从 Android Emulator 访问 localhost,但在 Simulator 上它正在工作 - Can't access localhost from Android Emulator, but on Simulator it's working 为什么Android模拟器无法从在线服务器访问API? - Why Android emulator can't access API from online server? 从android模拟器调试https - debugging https from android emulator 无法从3.2仿真器访问Internet - can't access Internet from 3.2 emulator 如何通过Android模拟器从PC访问我的Web应用程序? - How can I access my webapp from my pc by Android emulator? 无法在反应本机“/bin/sh:adb:找不到命令”中访问我的android模拟器 - Can't access my android emulator in react native “/bin/sh: adb: command not found” 我的电脑通过 VPN 连接,Android 模拟器无法访问本地内网站点 - My computer is connected over a VPN, Android emulator can't access local intranet sites 无法从 android 模拟器连接到 localhost - Can't connect to localhost from android emulator 无法从Android Windows模拟器(Visual Studio 2015 / Xamarin)访问localhost - Can't access localhost from Android Windows Emulator (Visual Studio 2015 / Xamarin) 我在 android 模拟器上看不到 ParsePush 通知 - I can't see my ParsePush Notification on my android emulator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM