cordova“释放”行为不同于“调试”关于SSL [英] cordova "release" behaves differently to "debug" regarding SSL

查看:204
本文介绍了cordova“释放”行为不同于“调试”关于SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常困难和完全不可能的问题cordova。

I have very difficult and totally ungoogleable problem with cordova.

一个程序,工作完美编译在 - debug 模式,在 - release 模式下编译后停止工作。
我确保源是相同的,效果是恒定的。

A program, working perfectly being compiled in --debug mode, ceases working after compilation in --release mode. I made sure the source is identical, and the effect is constant.

- debug build和 - release build是 - release 构建无法打开任何SSL

The only difference between --debug build and --release build is that the --release build fails to open any SSL connections.

这个问题本地化非常狭窄,在我的例子中是以下行:

This problem is localized very narrow, in my case it is the following line:

Socket = new WebSocket('wss://376.su/');

我的一位朋友报告了同一行错误:

a friend of mine has reported the same error occurrence in the line:

<img src="https://blabla" />;

UPD:问题解决了,看答案。

UPD: the problem is solved see the answers.

推荐答案

问题



我已经确定问题的确切来源,我找到了完美的解决方案。原来是两个单独的问题的叠加,每个都是严重误导:

Problem

I have identified the exact source of the problem and i have found the perfect solution. It turned out to be a superposition of two separate issues each of which is seriously misleading:


  1. 我的SSL证书从Thawte

  1. My SSL certificate from Thawte (despite its cost) is not recognized by Android 5.1.1 as a valid one (while being recognized by all desktop browsers)

- 所有桌面浏览器都能识别它的成本)

转到项目的目录并找到以下文件:

Solution

Go to your project's directory and find the following file:

platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java

找到方法定义( onReceivedSslError )和以下条件:

Locate the method definition (onReceivedSslError) and the following condition:

(appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0

这是使 - debug - release 不同的原因。
为了忽略证书错误,应该执行以下代码:

This is what makes --debug and --release different. In order to ignore certificate "errors" the following code should be executed:

handler.proceed();
return;

此文件在构建过程中保持不变。
下次在您的项目中添加平台时,不要忘记忽略这些准错误。

This file persists through the build process. Don't forget to ignore those quasi-errors next time you add a platform to your project.

这篇关于cordova“释放”行为不同于“调试”关于SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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