diff options
| -rw-r--r-- | config.xml | 5 | ||||
| -rwxr-xr-x | hooks/before_prepare/01_pp_hacks.sh | 24 | ||||
| -rwxr-xr-x | www/js/DataModel.js | 34 | ||||
| -rw-r--r-- | www/js/FirstUseCtrl.js | 10 | ||||
| -rwxr-xr-x | www/js/app.js | 13 | ||||
| -rw-r--r-- | www/lang/locale-en.json | 1 | ||||
| -rw-r--r-- | www/templates/devoptions.html | 5 |
7 files changed, 76 insertions, 16 deletions
@@ -1,5 +1,5 @@ <?xml version='1.0' encoding='utf-8'?> -<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninjapro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.2.37" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> +<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninjapro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.2.38" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>zmNinja</name> <description> High performance ZoneMinder client @@ -30,6 +30,9 @@ <preference name="SplashMaintainAspectRatio" value="true" /> <preference name="FadeSplashScreen" value="false" /> <preference name="BackgroundColor" value="#444444" /> + <feature name="CDVCertificate"> + <param name="ios-package" onload="true" value="CDVCertificate" /> + </feature> <feature name="StatusBar"> <param name="ios-package" onload="true" value="CDVStatusBar" /> </feature> diff --git a/hooks/before_prepare/01_pp_hacks.sh b/hooks/before_prepare/01_pp_hacks.sh index 0d031741..d049f8e7 100755 --- a/hooks/before_prepare/01_pp_hacks.sh +++ b/hooks/before_prepare/01_pp_hacks.sh @@ -43,18 +43,18 @@ else echo "Directory platforms/android/res/ does not exist, skipping..." fi -echo "Fixing insecure SSL permission problem" -echo "--------------------------------------------------" -if [ -d "platforms/android/CordovaLib/src/org/apache/cordova/engine" ]; then - exe cp www/external/SystemWebViewClient.java platforms/android/CordovaLib/src/org/apache/cordova/engine -else - echo "Directory platforms/android/CordovaLib/src/org/apache/cordova/engine does not exist, skipping..." -fi -if [ -d "platforms/ios/zmNinja/Classes" ]; then - exe cp www/external/AppDelegate.m platforms/ios/zmNinja/Classes/ -else - echo "Directory platforms/ios/zmNinja/Classes does not exist, skipping..." -fi +#echo "Fixing insecure SSL permission problem" +#echo "--------------------------------------------------" +#if [ -d "platforms/android/CordovaLib/src/org/apache/cordova/engine" ]; then +# exe cp www/external/SystemWebViewClient.java platforms/android/CordovaLib/src/org/apache/cordova/engine +#else +# echo "Directory platforms/android/CordovaLib/src/org/apache/cordova/engine does not exist, skipping..." +#fi +#if [ -d "platforms/ios/zmNinja/Classes" ]; then +# exe cp www/external/AppDelegate.m platforms/ios/zmNinja/Classes/ +#else +# echo "Directory platforms/ios/zmNinja/Classes does not exist, skipping..." +#fi diff --git a/www/js/DataModel.js b/www/js/DataModel.js index d2b21c2c..40ed4738 100755 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -151,6 +151,7 @@ angular.module('zmApp.controllers') 'hideArchived': false, 'videoPlaybackSpeed': 2, 'enableGIFMP4': false, + 'enableStrictSSL': false, }; @@ -161,6 +162,27 @@ angular.module('zmApp.controllers') 'ZM_PATH_ZMS': '' }; + + function setSSLCerts() + { + if (!window.cordova) return; + if (!loginData.enableStrictSSL) + { + + //alert("Enabling insecure SSL"); + log(">>>> Disabling strict SSL checking (turn off in Dev Options if you can't connect)"); + cordova.plugins.certificates.trustUnsecureCerts(true); + + } + else + { + + log(">>>> Enabling strict SSL checking (turn off in Dev Options if you can't connect)"); + cordova.plugins.certificates.trustUnsecureCerts(false); + } + } + + // credit: http://stackoverflow.com/questions/4994201/is-object-empty function isEmpty(obj) { @@ -994,6 +1016,13 @@ angular.module('zmApp.controllers') } + if (typeof loginData.enableStrictSSL == 'undefined') + { + + loginData.enableStrictSSL = false; + + } + log("DataModel init recovered this loginData as " + JSON.stringify(loginData)); } else @@ -1001,6 +1030,11 @@ angular.module('zmApp.controllers') log("defaultServer configuration NOT found. Keeping login at defaults"); } + // now set up SSL - need to do it after data return + // from local forage + setSSLCerts(); + + // FIXME: HACK: This is the latest entry point into dataModel init, so start portal login after this // not the neatest way $rootScope.$emit('init-complete'); diff --git a/www/js/FirstUseCtrl.js b/www/js/FirstUseCtrl.js index e5692188..1dc6c514 100644 --- a/www/js/FirstUseCtrl.js +++ b/www/js/FirstUseCtrl.js @@ -16,6 +16,16 @@ angular.module('zmApp.controllers').controller('zmApp.FirstUseCtrl', ['$scope', { //console.log("**VIEW ** FirstUse Ctrl Entered"); $ionicSideMenuDelegate.canDragContent(true); + // right up here lets set certs to true, we will disable it later + // this is for first starts + + // + if (window.cordova) + { + cordova.plugins.certificates.trustUnsecureCerts(true); + NVRDataModel.log (">>>>>Accepting all certificates, since its first use"); + } + }); diff --git a/www/js/app.js b/www/js/app.js index d0f30afe..b006390a 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -1485,6 +1485,8 @@ angular.module('zmApp', [ $ionicPlatform.ready(function() { + + // handles URL launches // if you just launch zmninja:// then it will honor the settings in "tap screen" -> events or montage @@ -1694,8 +1696,7 @@ angular.module('zmApp', [ { $cordovaSplashscreen.hide(); - NVRDataModel.log("Enabling insecure SSL"); - cordova.plugins.certificates.trustUnsecureCerts(true); + cordova.getAppVersion.getVersionNumber().then(function(version) { @@ -1819,6 +1820,10 @@ angular.module('zmApp', [ { NVRDataModel.log("Language file loaded, continuing with rest"); NVRDataModel.init(); + + // now do SSL check + //setSSLCerts(); + EventServer.init(); zmCheckUpdates.start(); NVRDataModel.log("Setting up POST LOGIN timer"); @@ -1826,10 +1831,12 @@ angular.module('zmApp', [ setupPauseAndResume(); + } } + function setupPauseAndResume() { NVRDataModel.log("Setting up pause and resume handler AFTER language is loaded..."); @@ -2193,7 +2200,7 @@ angular.module('zmApp', [ { data: { - requireLogin: true + requireLogin: false }, url: "/devoptions", cache: false, diff --git a/www/lang/locale-en.json b/www/lang/locale-en.json index 61701716..aa6611e4 100644 --- a/www/lang/locale-en.json +++ b/www/lang/locale-en.json @@ -77,6 +77,7 @@ "kEnableLogs" :"Enable logs", "kEnableNewsUpdates" :"enable news updates", "kEnterPin" :"Enter PIN", + "kEnableStrictSSL" : "Enable strict SSL check", "kError" :"Error", "kErrorChangingMonitors" :"Error changing monitors. Please check logs", "kErrorFrameBanner" :"could not retrieve frame details", diff --git a/www/templates/devoptions.html b/www/templates/devoptions.html index e84ef7de..e72ffe72 100644 --- a/www/templates/devoptions.html +++ b/www/templates/devoptions.html @@ -116,6 +116,11 @@ </ion-toggle> </label> + <label ng-if="$root.platformOS!='desktop'"> + <ion-toggle ng-model="loginData.enableStrictSSL" ng-checked="loginData.enableStrictSSL" toggle-class="toggle-calm"><span class="item-text-wrap">{{'kEnableStrictSSL' | translate}} + </span> + </ion-toggle> + </label> <label> <ion-toggle ng-model="loginData.enableGIFMP4" ng-checked="loginData.enableGIFMP4" toggle-class="toggle-calm"><span class="item-text-wrap">{{'kEnableGIFMP4' | translate}} |
