Bypassing SSL certificate validation in headless Chrome for Codeception tests

I’m having trouble with my Codeception tests in headless Chrome. I tried adding some options to my acceptance.suite.yml file:

chromeOptions:
  args: ['--no-sandbox', '--disable-web-security', '--ignore-ssl-errors']

But it’s not working as expected. The tests get stuck on a blank page when running in headless mode. I think they might be hitting an ‘Insecure Connection’ warning and can’t get past it.

Has anyone found a way to make Chrome ignore SSL certificate errors in headless mode for Codeception? I’ve been scratching my head over this for hours. Any tips or tricks would be really helpful. Thanks in advance!

hey mikezhang, ran into smthing similar. try adding ‘–ignore-certificate-errors’ to ur args list. also, make sure ur using latest chrome/chromedriver versions. if that dont work, u might need to tweak ur php.ini file to allow insecure connections. good luck!

I’ve encountered this issue before in my Codeception projects. One solution that worked for me was using the ‘–disable-gpu’ argument along with ‘–ignore-certificate-errors’. Additionally, consider setting ‘DBUS_SESSION_BUS_ADDRESS=/dev/null’ as an environment variable before running your tests. This combination helped bypass SSL certificate validation in headless Chrome for me.

If you’re still facing issues, you might want to check your Codeception configuration to ensure it’s properly set up for headless Chrome. Also, verify that your test URLs are using ‘https://’ instead of ‘http://’ where applicable. These steps resolved the blank page problem in my case.

I’ve dealt with this headache before. What worked for me was tweaking the WebDriver configuration directly in the acceptance.suite.yml file. Try adding these lines:

WebDriver:
  url: 'your_base_url_here'
  browser: chrome
  capabilities:
    chromeOptions:
      args: ['--headless', '--disable-gpu', '--no-sandbox', '--ignore-certificate-errors']
      prefs:
        'profile.managed_default_content_settings.notifications': 2

This combo of args bypassed SSL issues for me. Also, make sure your Codeception version is up-to-date. If you’re still hitting a wall, consider using a self-signed certificate for your local environment. It’s a bit of extra setup, but it solved similar issues in one of my projects.

Lastly, double-check that your test scripts aren’t timing out before the page loads completely. Increasing the wait time might help if everything else checks out.