19

We have an application and testing this locally shows an invalid SSL certificate warning. Normally I would just add an exception and get on with it. However is there anyway for protractor to ignore this?

I've seen some capabilities in selenium where SSL can be ignored but can't seem to find any in protractor.

halfer
  • 19,824
  • 17
  • 99
  • 186
Joseph
  • 541
  • 1
  • 4
  • 31
  • Where did you encounter the issue? On running protractor? what is the exact error? what browser did you use or config file? Please add details on your question as much as possible. – Paul Co Dec 12 '17 at 10:35
  • I've seen this using both Firefox and Chrome. The error isn't an error, it is a warning within Firefox (I can't upload a screenshot) - but the text is "Your connection is not secure The owner of localhost has configured their website improperly. To protect your information from being stolen, Firefox has not connected to this website." The error code appears to be "localhost:4200 uses an invalid security certificate. The certificate is not trusted because it is self-signed. Error code: SEC_ERROR_UNKNOWN_ISSUER" – Joseph Dec 12 '17 at 10:50
  • on Chrome the error is NET::ERR_CERT_AUTHORITY_INVALID – Joseph Dec 12 '17 at 11:05
  • can you share the website? – Paul Co Dec 13 '17 at 04:32
  • @PaulCo - afraid not - it's an internal only development just now (which is why we don't have a proper SSL certificate yet.) – Joseph Dec 13 '17 at 10:37

3 Answers3

31

This works for me, (in conf file):

capabilities: {
    browserName : 'firefox',
    marionette : true,
    acceptInsecureCerts : true
}

Hope that helps.

M. Hudson
  • 889
  • 5
  • 11
4
capabilities: {
    browserName: 'chrome',
    chromeOptions: {
        // for ci test
        args: ['--headless', 'no-sandbox', "--disable-browser-side-navigation",
            "--allow-insecure-localhost"
            /// for https sites: ignore ssl on https://localhost...
            /// further args please see https://peter.sh/experiments/chromium-command-line-switches/
        ]
    }
}

maybe you want to take some screenshots to test where the error occurs

import fs from 'fs';

function writeScreenShot(data, filename) {
    const stream = fs.createWriteStream(filename);
    stream.write(new Buffer(data, 'base64'));
    stream.end();
}

export function takeScreenshot(browser, path){
    browser.takeScreenshot().then((png) => {
        writeScreenShot(png, path);
    });
}

But for the long run, I would suggest migrating to cypress (https://www.cypress.io/), because it have many other features out of the box: video, screenshot, etc. And believe me, it is worth it ;)

Yuqiu G.
  • 348
  • 4
  • 7
0

try

webdriver-manager update --ignore_ssl

or configure protractor.conf.js for firefox

var makeFirefoxProfile = function(preferenceMap) {
    var profile = new FirefoxProfile();
    for (var key in preferenceMap) {
        profile.setPreference(key, preferenceMap[key]);
    }
    return q.resolve({
        browserName: 'firefox',
        marionette: true,
        firefox_profile: profile
    });
};

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    framework: 'jasmine2',
    getMultiCapabilities: function() {
        return q.all([
            makeFirefoxProfile(
                {
                    'browser.acceptSslCerts': true
                }
            )
        ]);
    },
}
andriyze
  • 464
  • 3
  • 7
  • Currently running 12.0.6 - just about to test with the ignore ssl flag – Joseph Dec 13 '17 at 10:38
  • Ok ignore ssl flag didn't work. Can I ask a slight different question - is there a way to specify a profile for firefox in the config.js file which would allow me to permanently add an exception (it's not the nicest or best way but could get me round this) – Joseph Dec 13 '17 at 10:45
  • try something like this. (I updated the answer). Sorry unable to try on my side. – andriyze Dec 13 '17 at 15:10
  • I'll give this a go later on – Joseph Dec 13 '17 at 16:21