puppeteer: [problem] Mac OS Firewall popup on every launch of puppeteer

With every launch on mac os, it causes mac os to ask the following question

“Do you want to the application Chromium.app to accept incoming network connections?”

Steps to reproduce

  • Puppeteer version: 1.18.1
  • Platform / OS version: Mac OS Sierra 10.12.4
  • Node.js version:v11.2.0

What steps will reproduce the problem?

const browser = await puppeteer.launch({ headless: false })
and visit any url...

What is the expected result?

Chromium window appear with the site content

What happens instead?

Chromium window appear with the site content And the Mac OS alert pop ups asking “Do you want to the application Chromium.app to accept incoming network connections?”

No matter what you do with the Mac OS Firewall setting it keeps asking it again and again and again.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 75
  • Comments: 26 (2 by maintainers)

Commits related to this issue

Most upvoted comments

sudo codesign --force --deep --sign - ./node_modules/puppeteer/.local-chromium/mac-722234/chrome-mac/Chromium.app

This is what I used. It’ll prompt you for your password. Then the next time Chromium with a head opens up youll get the prompt one last time and youre good to go from then on. Enjoy!

Go to system preferences then create a self signed certificate (keychen app, “trousseaux d’acces” in french). Tell a name “MyCertificateName”, self signed root and code signing certificate type. Tell system that you trust it.

Capture d’écran 2019-08-22 à 23 24 55

Capture d’écran 2019-08-22 à 23 27 19

Open a command and write "codesign -s MyCertificateName -f ./tothepath/yourapp.app --deep

Your app is now self signed and trusted for all the system, you should not be notified anymore (it worked for me)

For me after creating the certificate, it was under “login” keychain so I had to drag and drop it to “System”, then run the command above again. image

As chromium revision in puppeteer is updated frequently I put --deep flag at the beginning of codesign command. So, after puppeteer update re-sign is very simple:

$ sudo codesign --deep -s Puppeteer -f ./node_modules/puppeteer/.local-chromium/ +[TAB]x3 +[ENTER]

My solution, based off @jesperronn

Add the following alias to your bash_profile of zsh_profile or whatever.

alias fix-chromium-permissions-locally="sudo codesign --force --deep --sign - ./node_modules/puppeteer/.local-chromium/mac-*/chrome-mac/Chromium.app"

Then run fix-chromium-permissions-locally in each project folder you need it. Also might be required each time node_modules is updated/reinstalled 👍

i made something a bit more generic, as every puppeteer version generate a different mac-xxxxx path image thanks for @Madvinking

const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');

function removeChromiumAlert() {
    try {
      const chromiumPath = '/chrome-mac/Chromium.app';
      const macPath = path.join(path.dirname(require.resolve('puppeteer')), '/.local-chromium/');
      const [generatedDir] = fs
        .readdirSync(macPath, { withFileTypes: true })
        .filter(dirent => dirent.isDirectory())
        .map(dirent => dirent.name);
      const chromiumAppPath = path.join(macPath, generatedDir, chromiumPath);
      const mode = `0${(fs.statSync(chromiumAppPath).mode & parseInt('777', 8)).toString(8)}`;

      if (mode !== '0777') {
        execSync(`sudo chmod 777 ${chromiumAppPath}`);
        execSync(`sudo codesign --force --deep --sign - ${chromiumAppPath}`);
      }
    } catch (err) {
      console.warn('unable to sign Chromium, u may see the annoying message when the browser start');
      console.warn(err);
    }
}

Here’s another option?

puppeteer.launch({
    args: [
      '--disable-features=DialMediaRouteProvider',
    ],
});

Assumes you’re not using whatever features the “DialMediaRouteProvider” provides

Works like a charm! Great fix!

Let me update the tutorial, ok?

App to run on Mac is: Keychain Access.app

  1. From top menu bar select Keychain > Certificate Assistant > Create a certificate
image
  1. Put in
  • name: Pupeteer
  • type: Code signature
image
  1. Finish the process

  2. Select first tab: All things and search for Pupeteer

Zrzut ekranu 2022-04-14 o 23 23 10
  1. Copy the certificate

  2. Select System > My certificates

Zrzut ekranu 2022-04-14 o 23 24 06
  1. Paste copied certificate Pupeteer

  2. Remove certificate from the previous place (was in Logging > My certificates).

  3. Find your chromium app path.

  4. Enter the signing command (my path):

sudo codesign --deep -s Pupeteer -f "/Users/me/WebstormProjects/MyProject/node_modules/puppeteer/.local-chromium/mac-970485/chrome-mac/Chromium.app"

I ended up adding a bash alias based on your suggestions:

alias sign_puppeteer="sudo codesign --force --deep \
    --sign - ./node_modules/puppeteer/.local-chromium/mac-*/chrome-mac/Chromium.app"

Here’s another option?

puppeteer.launch({
    args: [
      '--disable-features=DialMediaRouteProvider',
    ],
});

Assumes you’re not using whatever features the “DialMediaRouteProvider” provides

This is still an issue I have experienced it. This process needs to be documented somewhere. The steps to fix this issue should not be in a github issue.

Thanks, sudo codesign -s Puppeteer -f ./node_modules/puppeteer/.local-chromium/mac-674921/chrome-mac/Chromium.app --deep worked. Note that sudo is needed but it doesn’t complain if it’s missing.

Let me update the tutorial, ok?

App to run on Mac is: Keychain Access.app

  1. From top menu bar select Keychain > Certificate Assistant > Create a certificate
image
  1. Put in
  • name: Pupeteer
  • type: Code signature
image
  1. Finish the process
  2. Select first tab: All things and search for Pupeteer
Zrzut ekranu 2022-04-14 o 23 23 10
  1. Copy the certificate
  2. Select System > My certificates
Zrzut ekranu 2022-04-14 o 23 24 06
  1. Paste copied certificate Pupeteer
  2. Remove certificate from the previous place (was in Logging > My certificates).
  3. Find your chromium app path.
  4. Enter the signing command (my path):
sudo codesign --deep -s Pupeteer -f "/Users/me/WebstormProjects/MyProject/node_modules/puppeteer/.local-chromium/mac-970485/chrome-mac/Chromium.app"

Thanks! That popup was getting me crazy!

Can a signed Chromium be bundled in?