31

I have a node application that uses puppeteer to test a web site. Up until we updated to latest puppeteer 1.12.2 we had no problem.

  1. Node launches puppeteer on timer
  2. On every launch, system asks: "Do you want to the application Chromium.app to accept incoming network connections"

In the Firewall tab of the "Security and Privacy" settings, ACCEPT is specifically set for Chromium. (and we've tried turning it off too) There seems to be no pleasing MacOS on this point.

Any suggestions about how to quiet MacOS and recognize/persist the firewall preference?

Eric Oemig
  • 487
  • 6
  • 9

4 Answers4

16

We were having the same issue after upgrade our puppeteer and MacOS. One solution we have is to instruct puppeteer to use our own Chrome instead of the bundled chromium by specifying the executablePath. Below is a Typescript snippet how we specify it. Same thing if you use vanilla JS.

Sometimes that still is not enough, we have to make headless option false to make it consistently work, which is really annoying.

      /**
       * create a puppeteer 'Browser' object.
       */
      public static createBrowser(): Promise<Browser> {
        return puppeteer.launch({
          // ... other options
          headless: false,
          executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
        });
      }

Hope it also works for you. :-)

LeOn - Han Li
  • 9,388
  • 1
  • 65
  • 59
9

Another option is self sign a certificate, follow the instructions in this comment:

https://github.com/GoogleChrome/puppeteer/issues/4752#issuecomment-524086077

Here in more detail how to open the Certificate creator: https://support.apple.com/en-gb/guide/keychain-access/kyca2686/mac)

And then in the root of your repo run:

sudo codesign -s MyCertificateName -f ./node_modules/puppeteer/.local-chromium/mac-674921/chrome-mac/Chromium.app --deep

blub
  • 8,757
  • 4
  • 27
  • 38
  • Could not manage to do this option. Hope any tutorial exists on YouTube – Serkan AKMAN May 22 '20 at 17:28
  • 1
    I was struggling to find the certificate assistant. The beginning of [this article](https://www.ssl.com/how-to/csr-generation-in-macos-keychain-access-2/) was helpful – Joshua Wootonn Mar 02 '21 at 23:18
  • This is the right procedure. I've tried it: I had to authorize one last time and now no need to do it each time! Thanks! – Jerome Jul 13 '21 at 08:30
4

In my case it was using a globally installed version of chromium (from playwright). So the following command worked in signing it:

global chromium

sudo codesign --force --deep --sign - ~/Library/Caches/ms-playwright/chromium-*/chrome-mac/Chromium.app

If you don't use a global chromium install, the following might work

local project chromium

sudo codesign --force --deep --sign - ./node_modules/puppeteer/.local-chromium/mac-*/chrome-mac/Chromium.app
Ben Winding
  • 10,208
  • 4
  • 80
  • 67
  • Did not work for my playwright setup unfortunately. – Daan Klijn Nov 09 '21 at 15:08
  • 1
    @Daan see updated answer for local project – Ben Winding Nov 10 '21 at 01:04
  • in newer puppeteer versions, chromium is stored in a different module called puppeteer-core. So, adjust the above local script to this `sudo codesign --force --deep --sign - ./node_modules/puppeteer-core/.local-chromium/mac-*/chrome-mac/Chromium.app` – jbmilgrom Nov 15 '22 at 21:26
3

1. Find puppeteer location

I found Chromium using the node command and running the following code.

const puppeteer = require('puppeteer');
console.log(puppeteer.executablePath());

2. Codesign puppeteer

The method that worked for me was the one in this answer.

sudo codesign --force --deep --sign - <PATH_FROM_STEP_1>

Note: It still asked for permission the first time after running this command but after that it didn't ask anymore.

Ryan Rabello
  • 53
  • 1
  • 8