gpt4 book ai didi

android - 在 443 以外的端口上使用 SSL 时收到 400 错误请求?

转载 作者:行者123 更新时间:2023-11-30 03:18:31 24 4
gpt4 key购买 nike

我在端口 9443 上有一个服务器。它使用由 godaddy 为“example.com”签名的 ssl 证书。我尝试连接到如下网址:

https://example.com:9443/api/v1/foo

这在我编写的 ios 应用程序和桌面浏览器中运行良好。如果我尝试从 Android 手机连接,我会收到 400 错误请求响应。我通过 chrome for android 尝试了同样的操作,它给了我:

ERR_TUNNEL_CONNECTION_FAILED

服务器也在监听端口 443,使用自签名证书,Android 客户端在那里工作正常(我确实需要一些额外的代码来让我的应用程序信任自签名证书)。

Android 中是否有一些限制,其中 https 必须使用端口 443?我在想,因为我使用的是合法的 ssl 证书,所以我不需要任何自定义代码来强制应用程序信任该证书。我的连接代码:

HttpParams params = new BasicHttpParams();
DefaultHttpClient client = new DefaultHttpClient(params);
HttpResponse response = client.execute(request);
Result result = new Result(response.getStatusLine().getStatusCode());

response.getStatusLine().getStatusCode(); // 400
response.getStatusLine().toString(); // HTTP/1.1 400 Bad Request

谢谢

最佳答案

我认为有两种可能性。

搜索 ERR_TUNNEL_CONNECTION_FAILED android 会将我带到 this page ,作者声称:

Android for some unknown reason will not allow you to use unstandard ports for SSL (i.e. only port 443 works when using https)

I confirmed this by trying a SSL website on port 2000 using my wifes iphone on AT&T. Sure enough it worked fine. So its not AT&T. Also worth pointing out it works fine on wifi.

Hopefully this is just a bug and will be fixed in the future.

然而,this site声称通过代理访问站点时发生错误。您的 Android 手机上可能配置了一个代理,它正试图以某种方式使用。

判断您身处哪个世界的最简单方法是使用不同的 Android 手机进行检查(如果您有的话)。

关于android - 在 443 以外的端口上使用 SSL 时收到 400 错误请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19602092/

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