cordova “release” behaves differently to “debug” regarding SSL

前端 未结 3 1880
梦毁少年i
梦毁少年i 2020-12-05 11:49

I have very difficult and totally ungoogleable problem with cordova.

A program, working perfectly being compiled in --debug mode, ceases working after c

3条回答
  •  抹茶落季
    2020-12-05 12:09

    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. 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)

    2. The --debug flag in cordova build simply ignores certificate "errors" (silently).

    Solution

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

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

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

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

    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.

提交回复
热议问题