Bug 1103196 - Add acceptInsecureCerts capability. r=automatedtester, a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 02 Dec 2016 07:45:00 -0500
changeset 352823 00acff678bfba629a09f9c0f630046f673146ded
parent 352822 c0e5bdc1b1efce3c40d3e8440be95eb5bafcaf23
child 352824 173b42a07f065cc8ee452b2223642fb670cd60a8
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester, test-only
bugs1103196
milestone52.0a2
Bug 1103196 - Add acceptInsecureCerts capability. r=automatedtester, a=test-only Reads the `acceptInsecureCerts` capability and sets the session state. MozReview-Commit-ID: KVErmdxwXQB
testing/marionette/driver.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -118,16 +118,20 @@ this.GeckoDriver = function(appName, ser
   this.observing = null;
   this._browserIds = new WeakMap();
 
   // user-defined timeouts
   this.scriptTimeout = 30000;  // 30 seconds
   this.searchTimeout = null;
   this.pageTimeout = 300000;  // five minutes
 
+  // Unsigned or invalid TLS certificates will be ignored if secureTLS
+  // is set to false.
+  this.secureTLS = true;
+
   // The curent context decides if commands should affect chrome- or
   // content space.
   this.context = Context.CONTENT;
 
   this.importedScripts = new evaluate.ScriptStorageService(
       [Context.CHROME, Context.CONTENT]);
   this.sandboxes = new Sandboxes(() => this.getCurrentWindow());
   this.actions = new action.Chain();
@@ -139,16 +143,17 @@ this.GeckoDriver = function(appName, ser
   this.testName = null;
 
   this.sessionCapabilities = {
     // mandated capabilities
     "browserName": Services.appinfo.name.toLowerCase(),
     "browserVersion": Services.appinfo.version,
     "platformName": Services.sysinfo.getProperty("name").toLowerCase(),
     "platformVersion": Services.sysinfo.getProperty("version"),
+    "acceptInsecureCerts": !this.secureTLS,
 
     // supported features
     "raisesAccessibilityExceptions": false,
     "rotatable": this.appName == "B2G",
     "acceptSslCerts": false,
     "proxy": {},
 
     // proprietary extensions
@@ -642,16 +647,24 @@ GeckoDriver.prototype.setSessionCapabili
     throw new SessionNotCreatedError(
         `Not all requiredCapabilities could be met: ${JSON.stringify(errors)}`);
   };
 
   // clone, overwrite, and set
   let caps = copy(this.sessionCapabilities);
   caps = copy(newCaps, caps);
   logger.config("Changing capabilities: " + JSON.stringify(caps));
+
+  // update session state
+  this.secureTLS = !caps.acceptInsecureCerts;
+  if (!this.secureTLS) {
+    logger.warn("Invalid or self-signed TLS certificates " +
+        "will be discarded for this session");
+  }
+
   this.sessionCapabilities = caps;
 };
 
 GeckoDriver.prototype.setUpProxy = function(proxy) {
   logger.config("User-provided proxy settings: " + JSON.stringify(proxy));
 
   assert.object(proxy);
   if (!proxy.hasOwnProperty("proxyType")) {