10

We're using headless Chrome for an application testing. We have a page that refuses to redirect in headless mode but redirects perfectly fine when not running headless. The response header contains the URL to redirect to, and a 302 status code is returned.

What would cause Chrome to behave differently when running in headless mode? Is there any logging that would help me to determine why the redirect isn't working as expected?

Edit: Found some more info. It looks like I'm unable to redirect to sites with bad certs. How can I deal with ERR_CERT_AUTHORITY_INVALID when running Chrome in headless mode?

sudo
  • 548
  • 1
  • 4
  • 16
Nael
  • 1,479
  • 1
  • 14
  • 20
  • 1
    Did you manage to solve this? We are experiencing the same issue. – Mark Micallef Nov 23 '17 at 21:34
  • I think I am experiencing the same issue. Do you know how to debug or at least get some better logging to find out what is going on? – karlos Dec 04 '17 at 19:26
  • Some options to pass to have chrome-headless send more debugging info: --log-level=0 --enable-logging --v=1 bug tracker for chrome/chromium headless not accepting the --ignore-certificate-errors flag: https://bugs.chromium.org/p/chromium/issues/detail?id=721739 – karlos Dec 07 '17 at 20:15
  • What I did is to disable the HTTPS in headless testing. – Player1 Dec 11 '17 at 14:39
  • I tried --ignore-certificate-errors but this did not work for me. My webpage re-directs to another login page due to OAUTH2. Is there any up date on this issue and a fix? – snikt Apr 12 '19 at 22:57
  • @snikt Can you explain what is the problem. Because OP question is about "NOT REDIRECTING". And solution is to MAKE redirect to the Auth page. – GensaGames Jan 13 '21 at 05:20

2 Answers2

3

I was having the same issue and as you pointed out it happens with sites that have bad certificates. Passing the --ignore-certificate-errors flag didn't work at the time of the original post as there was a bug.

Some options to pass to have chrome-headless send more debugging info: --log-level=0 --enable-logging --v=1 bug tracker for chrome/chromium headless not accepting the --ignore-certificate-errors flag: bugs.chromium.org/p/chromium/issues/detail?id=721739 – karlos Dec 7 '17 at 20:15

For anyone reading now the bug was patched recently here: https://chromium.googlesource.com/chromium/src.git/+/c8f0691b18dc5d941d5b6b3c67a483da02400670

And the --ignore-certificate-errors flag should allow redirects to occur when using headless chrome for sites with bad certificates.

poppa_nick
  • 31
  • 3
  • I tried --ignore-certificate-errors but this did not work for me. My webpage re-directs to another login page due to OAUTH2. Is there any up date on this issue and a fix? – snikt Apr 12 '19 at 18:49
3

as to date seems like --enable-features=NetworkService solves the issue of self signed certificated in headless mode

Daniel
  • 89
  • 2
  • 5
  • This works! We had to add `--shm-size=1g` to our Docker run command otherwise it broke with `selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash` – oschlueter Aug 30 '18 at 09:16
  • I tried --ignore-certificate-errors but this did not work for me. My webpage re-directs to another login page due to OAUTH2. Is there any up date on this issue and a fix? – snikt Apr 12 '19 at 22:57