puppeteer icon indicating copy to clipboard operation
puppeteer copied to clipboard

How do I get rid of popup for chromium certificates selection, can I set it programmatically ?

Open fusionx1 opened this issue 8 years ago • 27 comments

Is there another way without disabling the popup via puppeteer launch ? I tried dialog stuff but it seems not the way.

screen shot 2017-08-25 at 5 20 42 pm

fusionx1 avatar Aug 25 '17 09:08 fusionx1

Would the ignoreHTTPSErrors option in puppeteer.launch help you?

aslushnikov avatar Aug 25 '17 17:08 aslushnikov

This seems like it's related to managed policies: https://stackoverflow.com/a/27859775/315562 ignoreHTTPSErrors doesn't help me on this.

Looks like Chromium runs without the managed policies of the machine, which is good in the sense that it runs in a clean state (not inheriting machine's settings). Or it could just be doing this because the managed application is "Google Chrome", not set to "Chromium". However, there seems to be no API to toggle or add managed policies for through puppeteer.

Maybe following the Debugging section of this helps: http://www.chromium.org/administrators/mac-quick-start

chrisirhc avatar Aug 26 '17 02:08 chrisirhc

You are right @chrisirhc, there should be an api to toggle this, for others running the script headlessly. I tried using chrome canary as my executable_path but still not working.

fusionx1 avatar Aug 26 '17 07:08 fusionx1

I run into the same certificate popup dialog, anybody knows how to get rid of it?

laispace avatar Oct 25 '17 13:10 laispace

@fusionx1 How do you solve the problem finally?

laispace avatar Oct 25 '17 13:10 laispace

Still unresolve

On Wed, Oct 25, 2017 at 9:34 PM, 赖小赖 [email protected] wrote:

@fusionx1 https://github.com/fusionx1 How do you solve the problem finally?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GoogleChrome/puppeteer/issues/540#issuecomment-339331509, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnPOnvc1POoMzldr8N8FqO7b_EQbxVaks5svzkAgaJpZM4PCbXv .

fusionx1 avatar Oct 25 '17 14:10 fusionx1

I have the same problem, hope it to be resolved as soon as possible.

lewis617 avatar Dec 11 '17 09:12 lewis617

Same problem here, but I want to select one certificate to "log in" @aslushnikov you were asking for an example of this here: https://github.com/GoogleChrome/puppeteer/issues/1319#issuecomment-356499820

dvil88 avatar Jan 30 '18 16:01 dvil88

This solution worked for me! So I share it with everyone here. https://www.chromium.org/administrators/policy-list-3#AutoSelectCertificateForUrls

lewis617 avatar Feb 10 '18 18:02 lewis617

I successfully worked around this on OS X 10.13 just now with Chromium 68.0.3419.0. Setting the AutoSelectCertificateForUrls policy is the right approach. But the documentation at https://www.chromium.org/administrators/policy-list-3#AutoSelectCertificateForUrls is wrong.

The commands that worked for me:

defaults write org.chromium.Chromium AutoSelectCertificateForUrls -array
defaults write org.chromium.Chromium AutoSelectCertificateForUrls -array-add -string '{"pattern":"[*.]example.com","filter":{}}'

The format of the pattern is the key; the policy docs give an example of https://www.example.com but the actual value apparently needs to be a hostname pattern rather than a URL pattern. (I'm not 100% sure of that, but URL patterns don't work for me and the format above does.)

In this example I left the filter blank since I don't need filtering for my use case, but you can put a value there if you need one.

This isn't ideal since you're setting the preference for all Chromium invocations for your account rather than for a specific Puppeteer invocation. It would definitely be better to have an API to set this, and for that matter to programmatically supply a client certificate rather than using the system keychain. But the workaround at least helps.

sgrimm-sg avatar Jun 05 '18 17:06 sgrimm-sg

Was there any update on this? Electron has a well working api for client certificate selection.

In my case client certificate is different for each user (SubjectName) and I need to provide it before I'm presented with the login screen. I can do this easily with electron, but I'm stucked with puppeteer and can't figure out if the pattern in auto selection can achive this without me setting each time with a fixed subject name before I lunch chrome via puppeteer.

paolocaminiti avatar Aug 05 '18 17:08 paolocaminiti

Yes there is a solution to this!

@dapriett shows in this comment how you can intercept Puppeteer's network request using page.setRequestInterception, and then make the request manually yourself with the necessary cert data, and then set the response using interceptedRequest.respond. In his example he uses request, but you could use anything that allows you to set the cert information on an HTTP request.

camjackson avatar Oct 12 '18 10:10 camjackson

headless not working~

Explorer1092 avatar Nov 14 '18 14:11 Explorer1092

@Explorer1092 Did you ever figure out how to get this working with headless mode?

OhWhenELC avatar May 09 '19 19:05 OhWhenELC

The solution given in this comment is working perfectly: https://github.com/GoogleChrome/puppeteer/issues/1319#issuecomment-371503788

You can use multiple certificates to login in the same webpage without touching the security policies. The thread is already referenced in this one.

dvil88 avatar Jun 06 '19 16:06 dvil88

This solution worked for me! So I share it with everyone here. https://www.chromium.org/administrators/policy-list-3#AutoSelectCertificateForUrls

what should I do exactly to make it work?

I am using puppeteer with default chromium

filozof6 avatar Aug 23 '19 19:08 filozof6

@Explorer1092 Did you ever figure out how to get this working with headless mode?

Yes, this would be CI/CD practical if it worked in headless mode. I’ve been trolling the internet for weeks trying to solve it in headless mode.

bordencastle avatar Aug 24 '19 12:08 bordencastle

Did anyone manage to get this working on headless mode?

lester289 avatar Sep 26 '19 07:09 lester289

Did anyone manage to get this working on headless mode?

Not exactly, but we built a reverse proxy servlet and extended the chromedriver in java. Another easier workaround is just to install a Nginx, Apache, etc... web server and use that to proxy all your requests and inject the certificate headers. In either case, proxy the requests.

bordencastle avatar Sep 26 '19 10:09 bordencastle

@lester289 @bordenit

GOTO:

The solution given in this comment is working perfectly: #1319 (comment)

You can use multiple certificates to login in the same webpage without touching the security policies. The thread is already referenced in this one.

dvil88 avatar Sep 26 '19 10:09 dvil88

The workaround in https://github.com/GoogleChrome/puppeteer/issues/1319#issuecomment-371503788 does not work for form submissions that include file uploads, because https://github.com/puppeteer/puppeteer/issues/5097 prevents request interceptors from reading multipart payloads.

sgrimm avatar Jul 01 '20 19:07 sgrimm

Did anyone manage to get this working?

I've some doubts, with the workaround in https://github.com/puppeteer/puppeteer/issues/1319#issuecomment-371503788 should chromium show a valid SSL connection? (with the padlock)

I'm trying to use a pfx certificate but seems like the site doesn't recognize it

agentOptions: {
    requestCert: true,
    rejectUnauthorized: false,
    pfx: fs.readFileSync(__dirname + '/certs/cert.pfx'),
    passphrase: 'passphrase'
}

gepd avatar Sep 15 '20 02:09 gepd

I successfully worked around this on OS X 10.13 just now with Chromium 68.0.3419.0. Setting the AutoSelectCertificateForUrls policy is the right approach. But the documentation at https://www.chromium.org/administrators/policy-list-3#AutoSelectCertificateForUrls is wrong.

The commands that worked for me:

defaults write org.chromium.Chromium AutoSelectCertificateForUrls -array
defaults write org.chromium.Chromium AutoSelectCertificateForUrls -array-add -string '{"pattern":"[*.]example.com","filter":{}}'

The format of the pattern is the key; the policy docs give an example of https://www.example.com but the actual value apparently needs to be a hostname pattern rather than a URL pattern. (I'm not 100% sure of that, but URL patterns don't work for me and the format above does.)

In this example I left the filter blank since I don't need filtering for my use case, but you can put a value there if you need one.

This isn't ideal since you're setting the preference for all Chromium invocations for your account rather than for a specific Puppeteer invocation. It would definitely be better to have an API to set this, and for that matter to programmatically supply a client certificate rather than using the system keychain. But the workaround at least helps.

This worked like a charm. Thank you!

In my case, I was actually running into this issue in the Sidekick browser (a really awesome Chrome alternative built on Chromium). In case anyone out there is dealing the same issue and stumbles across this thread as I did, you just need to change the plist file name to com.pushplaylabs.sidekick, so the terminal commands become:

defaults write com.pushplaylabs.sidekick AutoSelectCertificateForUrls -array
defaults write com.pushplaylabs.sidekick AutoSelectCertificateForUrls -array-add -string '{"pattern":"[*.]example.com","filter":{}}'

And as mentioned, be sure your pattern matches the hostname, NOT the full URL pattern.

jonnyasmar avatar Sep 29 '21 18:09 jonnyasmar

O mesmo problema aqui, mas quero selecionar um certificado para "fazer login" @aslushnikov você estava pedindo um exemplo disso aqui: https://github.com/GoogleChrome/puppeteer/issues/1319#issuecomment-356499820

I'm having this problem in 2021, I need to select a specific certificate, could you reference me a solution?

jeronimo3875br avatar Nov 23 '21 00:11 jeronimo3875br

I couldn't find any solution for the pop-up certificate issue? Has anybody resolved this?

nirmalasubu avatar Jul 04 '22 17:07 nirmalasubu

The request interception isnt working. The certificate modal is still opened. How do I proceed? Anyone got a clue?

igorovisk avatar May 10 '24 20:05 igorovisk

same problem i dont found solution to the popup and select certificate :(

aallvi avatar Jan 14 '25 16:01 aallvi