使用自签名证书对 HTTPS 服务器进行 PhoneGap Ajax 调用失败

发布于 2024-12-28 18:45:26 字数 240 浏览 0 评论 0原文

我对phonegap 比较陌生,最近我在我的windows apache 服务器上使用自签名证书设置了HTTPS/SSL,并尝试发出HTTPS ajax post 请求。该请求在浏览器中运行时工作正常,但在phonegap 中运行时失败。我尝试将 android:debuggable 设置为 false 但这并没有解决问题。我还做了一些研究,看来phonegap确实支持HTTPS ajax请求,所以我很困惑为什么请求失败。

有谁知道为什么会这样?

I am relatively new to phonegap and I have recently set up HTTPS/SSL on my windows apache server with a self signed certificate and am trying to make an HTTPS ajax post request. The request works fine when ran in a browser but fails when run within phonegap. I tried setting android:debuggable to false but that did not fix the issue. I have also done some research and it appears that phonegap does support HTTPS ajax requests so I am confused as to why the request is failing.

Does anyone know why this could be?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱冒险 2025-01-04 18:45:26

这是 Joe Bowser 的一句话,他编写了允许在 PhoneGap Android 上进行自签名证书的代码:

  1. 如果您正在进行开发:清单中的 android:debuggable="true",您应该允许浏览器从服务器请求数据
    使用自签名或错误的 SSL 证书
  2. 如果您要发布应用程序,则应删除 android:debuggable="true" (Android Market 不允许您使用
    无论如何,你将无法将数据发送到服务器
    错误的 SSL 证书
  3. 如果您没有设置此标志,默认值将是现在的默认值,即您将无法将数据发送到
    具有自签名证书的服务器

所以看来您应该能够通过设置 android:debuggable="true" 来完成您想要的操作。如果这对您不起作用,我们需要向您提供重现方案、PhoneGap 版本以及您正在使用的 Android 版本。

也许最好为我们提出 Jira 中的错误:

https://issues.apache.org/jira/browse/CB#selectedTab=com.atlassian.jira.plugin.system.project%3Aissues-panel

This is a quote from Joe Bowser who wrote the code to allow self signed certs on PhoneGap Android:

  1. If you are doing development: android:debuggable="true" in the manifest, you should allow the browser to request data from servers
    with a self-signed or bad SSL cert
  2. If you are releasing an application, you should remove the android:debuggable="true" (Android Market won't let you release with
    this on anyway) and you will NOT be able to send data to a server with
    a bad SSL cert
  3. If you don't have this flag set, the default will be what the default is now, which is that you won't be able to send data to
    servers with a self-signed cert

So it seems like you should be able to do what you want by setting android:debuggable="true". If that isn't working for you we'll need to get a reproduction scenario from you, the version of PhoneGap and the version of Android you are using.

Probably best to raise a bug in Jira for us:

https://issues.apache.org/jira/browse/CB#selectedTab=com.atlassian.jira.plugin.system.project%3Aissues-panel

神爱温柔 2025-01-04 18:45:26

我在这个问题上花了几个小时,直到我发现有一个快速而肮脏的修复可能。它涉及重写 CordovaWebViewClient 以忽略证书错误。

I spent hours on this issue until I found that there is a quick and dirty fix possible. It involves overriding CordovaWebViewClient to ignore certificate errors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文