3

I am literally stuck to this problem for two days now.

Scenario:

The website that needs to be tested has a self signed certificate. So Internet Explorer (8 in windows XP_ shows

"The security certificate presented by this website was not issued by a trusted certificate authority. The security certificate presented by this website was issued for a different website's address."

Now this is perfectly natural in case of IE8 and self-signing certificates so I took the following measures to no use

  1. Manually added/installed the certificate as a Trusted Root Certificate in IE. But it doesn't get shown in the list, but it gets successfully added to all other tabs i.e. trusted root publisher,Intermediate Publisher Authority,Other People.
  2. The same certificate gets added to firefox without any problems under "servers" and works just as expected.
  3. I tried using the following codes but one of them worked for selenium

    Proxy proxy = new Proxy();
    proxy.setProxyType(ProxyType.MANUAL);
    Proxy.setSslProxy("trustAllSSLCertificates");
    DesiredCapabilities capabilities1 = DesiredCapabilities.internetExplorer();
    capabilities1.setCapability(CapabilityType.PROXY, proxy);
    

When this doesn't work I tried using

DesiredCapabilities capabilities = new DesiredCapabilities();
                            capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); 

I have the cybervillans certificate already installed.

  1. I have tried the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ERROR_PAGE_BYPASS_ZONE_CHECK_FOR_HTTPS_KB954312 method knowing full well it is for win7.

5.I have even tried changing the URL to the issued authority but even then the problem persists.

And now I am stuck with no alternatives. Can anyone point it out to me how I can proceed? It seems I'm eternally stuck with IE8.

I have searched a lot in Google as well as in this site. But couldn't find a solution to my problem.

Rabimba Karanjai
  • 186
  • 2
  • 5
  • 14

3 Answers3

0

When I use selenium across our dev/test versions of our websites I constantly get the IE screen for invalid certificates. To pass these, you send the following into the IWebDriver instance

driver.Navigate().GoToUrl("javascript:document.getElementById('overridelink').click()")

The screen you're seeing might be a little different to the bad certificate screen, so just tweak the getElementById selector to match the anchor's Id.

Robert Slaney
  • 3,712
  • 1
  • 21
  • 25
  • I know of that approach. BUt since my test pack will have to be cross browser compatible I need it to work for FF too. Now the Trust certificate works fine if I put it in trusted source in FF but in that case if I put this in my script then It will fail for FF (or chrome for that purpose)> That is my concern right now. – Rabimba Karanjai Jun 21 '12 at 10:26
  • Each browser handles certificate issues differently. When I use the ChromeDriver I pass the --ignore-certificate-errors argument. IE cannot do that, so I need a way of passing the form. Dunno about FF, I don't test using that browser very often. I also wrap a façade around the IWebDriver that allows negocation of SSL certificates to be customised per driver implementation – Robert Slaney Jun 27 '12 at 21:38
0

I use it like Robert wrote, like this:

 if (driver instanceof InternetExplorerDriver) {
        driver.navigate().to("javascript:document.getElementById('overridelink').click()");
    }
-1

This change will permanently accept all certificate errors in IE, but still, elegant solution: https://stackoverflow.com/a/7738795/2546759

Community
  • 1
  • 1
Nir
  • 1,836
  • 23
  • 26