Handling ERR_CERT_AUTHORITY_INVALID in Puppeteer within a Docker Environment

I am currently utilizing Puppeteer inside a Docker container to access a website secured with a custom SSL certificate. Here are the configuration steps I have followed:

  1. I installed google-chrome-stable in my Docker image following the guidelines found in the Puppeteer documentation.
  2. I placed my certificates in the directory /usr/local/share/ca-certificates inside the Docker container.
  3. Next, I directed Puppeteer to use the installed Google Chrome instance through the launch command:
    await puppeteer.launch({ executablePath: '/usr/bin/google-chrome' })
    
  4. I then made an attempt to visit my webpage with:
    await page.goto('https://my-page-url')
    

Nevertheless, upon executing this code within the Docker setup, I encounter the following error:

net:ERR_CERT_AUTHORITY_INVALID at https://my-page-url

This error suggests that Chrome fails to validate the SSL certificate for the destination site. What steps can I take to resolve this issue? I am aware of options like --ignore-certificate-errors, but I prefer to have Chrome connect successfully without bypassing the certificate verification.

To resolve ERR_CERT_AUTHORITY_INVALID without bypassing SSL verification, ensure your custom CA certificates are properly recognized by Chrome in your Docker environment:

  1. Install the CA certificates using update-ca-certificates after placing them in /usr/local/share/ca-certificates. Add this to your Dockerfile:
RUN cp /usr/local/share/ca-certificates/* /etc/ssl/certs/ \
    && update-ca-certificates
  1. Ensure Puppeteer launches with the system-installed CA certs. Pass args to the launch command:
await puppeteer.launch({
    executablePath: '/usr/bin/google-chrome',
    args: ['--no-sandbox', '--disable-setuid-sandbox']
});

Try these steps and verify if the website is accessible.