-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Client certificate authentication on pages. #1319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't understand. Can you please elaborate more on what's the usecaes? |
@aslushnikov I mean websites with mandatory or optional authentication via client certificates. I think on windows google chrome uses the certificates from the certificate store, but wouldn't it make sense to have a chrome/puppeteer api for that similar to how it supports basic authentication? |
@aslushnikov This chromium headless bug probably need to be solved first. |
@konstantinblaesi can you please give an example of such a website? Honestly, it looks like I have no idea about the topic. |
@aslushnikov This would support sites that use pki for authentication (vs user/pass or oauth). For testing work it would be helpful to be able to specify what cert chrome passes during the ssl handshake when the server requests a client certificate. I can't think of a public site that uses pki for authentication. It is somewhat common for intranet sites. |
Here is how I got around client cert authentication, hope it helps others. Basically just intercept the request, then fire the request off yourself using your favorite httpclient lib, and repond to the intercepted request with the response info.
|
Dupe of #540. |
So I know that 'thanks' and 'me too' comments are terrible, but I really just have to say THANK YOU to @dapriett for that solution! The entire internet seems to be filled with people asking how to get around the whole cert selection thing with puppeteer and various other browser automation libraries, and the above comment solves it beautifully! 👌 Note that |
One more update to the above solution by @dapriett - there is a bug with puppeteer where gzipped, intercepted responses are not decompressed correctly. See #1707. This is easily fixed though - when calling |
Thanks @dapriett, this solves the authentication, but when routing through |
@isakoala Looks like the stylesheet for the page isn't being loaded so you're just seeing raw, unstyled html. Or possible there are XHRs not loading either. I would just try adding a bunch of console logs within the request interception to see which requests are being made, which are getting responses back, etc, etc. |
FYI we've observed that when servers request certificate authentication from puppeteer/chromium it get's stuck when the request interception feature is enabled. We're basically hit by #3471 |
@camjackson indeed most stylesheets, all images and some other script files aren't loading. In my case, the latter was fatal because all post login content on the site I'm scraping is loaded using said scripts. Thanks, @konstantinblaesi, I'll keep an eye on that. |
@dapriett sorry about noob questions,
I only managed to download .crt file from broken website. |
This ticket is about a client authenticating to the webserver using certificates instead of credentials (e.g. basic auth). You or your organization will probably generate these files. |
@konstantinblaesi Another weird thing, is that same code works on AWS lambda. I know its really difficult to tell what's the issue,but any suggestions would be greatly appreciated. |
You can always tell puppeteer/chromium to ignore https errors by setting |
@konstantinblaesi Thanks for your help!
Every time I run Not sure how to check what CA are installed on google cloud. In documentation it is mentioned that https://github.com/GoogleChrome/puppeteer/blob/v1.13.0/docs/api.md#pagegotourl-options |
Hi @alexandrzavalii, as @konstantinblaesi said, this issue is about client cert authentication, which is a method for logging into websites by using an SSL certificate, rather than a username and password. It's an approach sometimes used by corporates for managing internal employee identities, but almost never used on the regular public internet. It sounds like your issue is more to do with SSL cert validation on a normal website, which is a completely different issue. Topic aside, github issues is really for bug and issue tracking rather than user support, so you might be better off asking a question on somewhere like stack overflow. Good luck! 🙂 |
Thanks for your intercept example, @dapriett. My use case isn't about certificate authentication specifically, but simply self-signed certificates created for the purpose of testing a webserver application (that cannot be server over non-https due to reasons). It bothers me to no end that people seem to equate the problems of
I obviously want my test to resemble how the software is used as closely as possible and I don't get that by disabling certificate verification. Some initial experimentation with request interception seemed to indicate that it did interfere with cookies and websockets 😞 |
this does not work for me it seems tho I intercept the request the browser just reloads and repeat the same request all over again :( |
@dapriett , @camjackson - Are you referring to a private key to validate the cer ? |
@dcr007 These are most likely public (cert) and private key (key) files of your client. They can be generated with openssl or similar tools. |
@konstantinblaesi - thanks for responding !, I managed to export the public(cert) from chrome from the website and then executing
|
@dcr007 unfortunately I cannot be of any further help, because I have no practical experience with puppeteer and client certificate auth. I would suggest asking via https://github.com/puppeteer/puppeteer#q-i-have-more-questions-where-do-i-ask and https://gitter.im/puppeteer-chat/Lobby |
My workaroud is use headfull puppeter running in docker without GUI using xvfb: Docker
Nodejs
Tested on render.com. Example project. More detailed Medium story |
this code is not working for me :( the page throw blank after accept the use of certificate with page.on('dialog', async dialog => { |
When i try doing the interception, I get an error: |
I've looked through open/closed issues and the puppeteer API documentation. Is an API planned/possible? Is there an alternative solution? Will puppeteer just use some global chrome profile + certificate store and use the client certificates installed on the host?
The text was updated successfully, but these errors were encountered: