Created
March 6, 2015 23:33
Revisions
-
lgarner created this gist
Mar 6, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ getCertificate: function getCertificate(aManifestURL) { let manifestURL = "app://system.gaiamobile.org/manifest.webapp"; // change. Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "appsService", "@mozilla.org/AppsService;1", "nsIAppsService"); let app = appsService.getAppByManifestURL(manifestURL); if (!app) { debug("ZZZ: Missing app"); return false; } let appDir = null; // Pre-installed apps (if Non-engr builds): appDir = FileUtils.getDir("coreAppsDir", ["webapps", app.id], false, true); if (!appDir.exists()) { // Privilaged apps: appDir = FileUtils.getDir("webappsDir", ["webapps", app.id], false, true); } // Since the app is supposed to be installed, this might work: // appDir = FileUtils.initWithPath(app.basePath); // appDir.append(app.id); let appPackage = appDir.clone(); appPackage.append("application.zip"); if (appPackage.exists()) { debug("ZZZ: object good."); } else { debug("ZZZ: object bad."); } let zipReader = Cc["@mozilla.org/libjar/zip-reader;1"] .createInstance(Ci.nsIZipReader); zipReader.open(appPackage); debug('has file: ' + zipReader.hasEntry("dev_cert.cer")); let devCertStream = zipReader.getInputStream("dev_cert.cer"); let devCert = NetUtil.readInputStreamToString(devCertStream, devCertStream.available()); devCertStream.close(); debug("Dev cert: " + devCert); }