Closed amittendulkar closed 1 year ago
Meanwhile I referred the earlier logged issues but couldn't find any resolution, https://github.com/microsoft/playwright/issues/5636 https://github.com/microsoft/playwright/issues/18293
Looks like your browser trusts the certificate, while your host system does not. That can happen since Chrome manages trusted CAs on its own. You should figure out why your OS (or Node.js running on it) does not trust the certificate.
Thanks @pavelfeldman. I have installed Playwright on Python. In my case, it is MS Edge that is trusting the certificate.
I am using a Python virtual environment for playwright installation. The python -m certifi
command has given me the certificate path it is using. I have appended the certificate chain under both venv certificate and the global certificate managed by Python.
Should I assume the playwright install
command will use the above Python certificate path? Or still is it using Node.js managed certificate?
Where does Node.js manage its certificates?
Looks like I got the solution. Indeed it is Node.js not finding the certificate. The below commands solved the issue,
C:\Users\amit_tendulkar>d:\venv\amazon\Scripts\activate
(amazon) C:\Users\amit_tendulkar>python -m certifi
D:\venv\amazon\lib\site-packages\certifi\cacert.pem
(amazon) C:\Users\amit_tendulkar>set NODE_EXTRA_CA_CERTS=D:\venv\amazon\lib\site-packages\certifi\cacert.pem
(amazon) C:\Users\amit_tendulkar>playwright install
Downloading Chromium 108.0.5359.29 (playwright build v1033) from https://playwright.azureedge.net/builds/chromium/1033/chromium-win64.zip
109.5 Mb [====================] 100% 0.0s
Chromium 108.0.5359.29 (playwright build v1033) downloaded to C:\Users\amit_tendulkar\AppData\Local\ms-playwright\chromium-1033
Downloading FFMPEG playwright build v1008 from https://playwright.azureedge.net/builds/ffmpeg/1008/ffmpeg-win64.zip
1.4 Mb [====================] 100% 0.0s
FFMPEG playwright build v1008 downloaded to C:\Users\amit_tendulkar\AppData\Local\ms-playwright\ffmpeg-1008
Downloading Firefox 106.0 (playwright build v1364) from https://playwright.azureedge.net/builds/firefox/1364/firefox-win64.zip
78.3 Mb [====================] 100% 0.0s
Firefox 106.0 (playwright build v1364) downloaded to C:\Users\amit_tendulkar\AppData\Local\ms-playwright\firefox-1364
Downloading Webkit 16.4 (playwright build v1735) from https://playwright.azureedge.net/builds/webkit/1735/webkit-win64.zip
73.6 Mb [====================] 100% 0.0s
Webkit 16.4 (playwright build v1735) downloaded to C:\Users\amit_tendulkar\AppData\Local\ms-playwright\webkit-1735
Thanks to the below Q&A, https://stackoverflow.com/questions/29283040/how-to-add-custom-certificate-authority-ca-to-nodejs
Browsers are not getting installed for me as well. Same error encountered. Any resolution for this ?
You need to do the following,
gc d:\root.crt | ac d:\cacert.pem
gc d:\child1.crt | ac d:\cacert.pem
gc d:\child2.crt | ac d:\cacert.pem
...
gc d:\childN.crt | ac d:\cacert.pem
set NODE_EXTRA_CA_CERTS=D:\caert.pem
on command line (or $env:NODE_EXTRA_CA_CERTS = 'D:\caert.pem'
in Powershell).playwright install
command should work properly.Website is not valid
You can ignore the invalid page error and click on the certificate icon to export/download the entire certificate chain locally.
Sir, No certificate option is displayed it it directly opening this site
@ResiakA, please click on the lock icon as indicated below.
Next, select "Connection is secure" menu item (this is Edge specific. You will see something similar in Chrome or Firefox)
Now click on the certificate icon,
You should see a certificate viewer as below. Click on the details tab,
Now select each certificate in the tree starting from root and click export to export those certificates (in your case the presented certificates will be different from the below screenshot),
Once exported, you will need to follow the instructions in my earlier comments to append those certificates in a single file and use it as an additional certificate store for the Node.js.
This surely looks helpful just a quick help Because i am new to this. How do we create a .PEM file sir ?
This surely looks helpful just a quick help Because i am new to this. How do we create a .PEM file sir ?
The first command gc d:\root.crt | ac d:\cacert.pem
should automatically create the PEM file if it doesn't exist.
Error occurred. Could you please help sir Files are stored at the location
@ResiakA, have you stored the certificate files at d:\? What are their names and paths? Accordingly the file path against the gc
command will change.
Kept them exactly as you explained sir... if it is okay i would like to get in touch for some guidance and help from you as i am a beginner. It would be a huge help for me. @9955366412 for the resolution please reach out sir. 🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
Please provide the output of the command, dir D:\*.crt
. It should return the your stored files. If it doesn't, provide the output of dir D:\root*
. I can't see the path inside D:\ in your image. Make sure they are in the root of D: and not under some sub-directory.
On top of above cacert.pem made ready, you need to do the below to make playwright to install browsers without errors. `npm config set strict-ssl=false
npm config set registry http://registry.npmjs.org/
npm config set cafile /path/to/your/cert.pem
set NODE_TLS_REJECT_UNAUTHORIZED=0`
Got to resolve this in VM with firewall protection. With Zscaler, if issues exists, please update policy in it and rerun the above.
You need to do the following,
- Visit https://playwright.azureedge.net and download the complete certificate chain
- Let's assume your certificates are stored as root.crt, child1.crt, child2.crt, ... , childN.crt etc. at D:\
- Now create an empty file say D:\cacert.pem and execute the below commands in Powershell,
gc d:\root.crt | ac d:\cacert.pem gc d:\child1.crt | ac d:\cacert.pem gc d:\child2.crt | ac d:\cacert.pem ... gc d:\childN.crt | ac d:\cacert.pem
- Now set the NODE_EXTRA_CA_CERTS variable as
set NODE_EXTRA_CA_CERTS=D:\caert.pem
on command line (or$env:NODE_EXTRA_CA_CERTS = 'D:\caert.pem'
in Powershell).- Now your
playwright install
command should work properly.
Thank you. You are a true gem ♥ 👍🏼
Hi @amittendulkar,
Even after performing all the steps, I am getting below error:
Downloading Chromium 117.0.5938.62 (playwright build v1080) from https://playwright.azureedge.net/builds/chromium/1080/chromium-win64.zip Error: connect ETIMEDOUT 192.0.2.1:443 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) { errno: -4039, code: 'ETIMEDOUT', syscall: 'connect', address: '192.0.2.1', port: 443 } Failed to install browsers Error: Failed to download Chromium 117.0.5938.62 (playwright build v1080), caused by Error: Download failure, code=1 at ChildProcess.<anonymous> (C:\Learning\Playwright\PlaywrightTrial\node_modules\playwright-core\lib\server\registry\browserFetcher.js:91:16) at ChildProcess.emit (node:events:514:28) at ChildProcess._handle.onexit (node:internal/child_process:291:12)
I tried increasing the PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT to 5 minutes. Still no luck. Can you or someone else please help me in fixing this.
Thanks in advance!
I suggest creating a new question for the above and give a reference to the current question as the error is different.
You need to do the following,
- Visit https://playwright.azureedge.net and download the complete certificate chain
- Let's assume your certificates are stored as root.crt, child1.crt, child2.crt, ... , childN.crt etc. at D:\
- Now create an empty file say D:\cacert.pem and execute the below commands in Powershell,
gc d:\root.crt | ac d:\cacert.pem gc d:\child1.crt | ac d:\cacert.pem gc d:\child2.crt | ac d:\cacert.pem ... gc d:\childN.crt | ac d:\cacert.pem
- Now set the NODE_EXTRA_CA_CERTS variable as
set NODE_EXTRA_CA_CERTS=D:\caert.pem
on command line (or$env:NODE_EXTRA_CA_CERTS = 'D:\caert.pem'
in Powershell).- Now your
playwright install
command should work properly.
How do you download the "complete certificate chain"? Export... button only exports 1 crt file.
You need to do the following,
- Visit https://playwright.azureedge.net and download the complete certificate chain
- Let's assume your certificates are stored as root.crt, child1.crt, child2.crt, ... , childN.crt etc. at D:\
- Now create an empty file say D:\cacert.pem and execute the below commands in Powershell,
gc d:\root.crt | ac d:\cacert.pem gc d:\child1.crt | ac d:\cacert.pem gc d:\child2.crt | ac d:\cacert.pem ... gc d:\childN.crt | ac d:\cacert.pem
- Now set the NODE_EXTRA_CA_CERTS variable as
set NODE_EXTRA_CA_CERTS=D:\caert.pem
on command line (or$env:NODE_EXTRA_CA_CERTS = 'D:\caert.pem'
in Powershell).- Now your
playwright install
command should work properly.How do you download the "complete certificate chain"? Export... button only exports 1 crt file.
Did you follow these instructions? https://github.com/microsoft/playwright/issues/19622#issuecomment-1364102545
You will need to click on each certificate in the chain and click export.
You need to do the following,
- Visit https://playwright.azureedge.net and download the complete certificate chain
- Let's assume your certificates are stored as root.crt, child1.crt, child2.crt, ... , childN.crt etc. at D:\
- Now create an empty file say D:\cacert.pem and execute the below commands in Powershell,
gc d:\root.crt | ac d:\cacert.pem gc d:\child1.crt | ac d:\cacert.pem gc d:\child2.crt | ac d:\cacert.pem ... gc d:\childN.crt | ac d:\cacert.pem
- Now set the NODE_EXTRA_CA_CERTS variable as
set NODE_EXTRA_CA_CERTS=D:\caert.pem
on command line (or$env:NODE_EXTRA_CA_CERTS = 'D:\caert.pem'
in Powershell).- Now your
playwright install
command should work properly.How do you download the "complete certificate chain"? Export... button only exports 1 crt file.
Did you follow these instructions? #19622 (comment)
You will need to click on each certificate in the chain and click export.
Extras certs were ignored for some reason:
@agray, please set $env:NODE_EXTRA_CA_CERTS
to the absolute path of the pem file instead of just the filename.
I see that you are changing directory and then trying the install. Hence is it not finding the pem file.
You need to do the following,
- Visit https://playwright.azureedge.net and download the complete certificate chain
- Let's assume your certificates are stored as root.crt, child1.crt, child2.crt, ... , childN.crt etc. at D:\
- Now create an empty file say D:\cacert.pem and execute the below commands in Powershell,
gc d:\root.crt | ac d:\cacert.pem gc d:\child1.crt | ac d:\cacert.pem gc d:\child2.crt | ac d:\cacert.pem ... gc d:\childN.crt | ac d:\cacert.pem
- Now set the NODE_EXTRA_CA_CERTS variable as
set NODE_EXTRA_CA_CERTS=D:\caert.pem
on command line (or$env:NODE_EXTRA_CA_CERTS = 'D:\caert.pem'
in Powershell).- Now your
playwright install
command should work properly.
At 2:51 AM, this finally worked for me. Thanks for saving me !
Hi, I am currently similar issue in downloading the browsers and trying to download the certificates but I could only download certificate named "Cisco Umbrella Root CA".
Hi @amittendulkar, I did exactly as you directed and yet I'm still getting the error
On top of above cacert.pem made ready, you need to do the below to make playwright to install browsers without errors. `npm config set strict-ssl=false
npm config set registry http://registry.npmjs.org/
npm config set cafile /path/to/your/cert.pem
set NODE_TLS_REJECT_UNAUTHORIZED=0`
Got to resolve this in VM with firewall protection. With Zscaler, if issues exists, please update policy in it and rerun the above.
Would this be safe to execute on a company laptop? @SabFloki
Would you endorse this steps? @amittendulkar
Hi @amittendulkar, I did exactly as you directed and yet I'm still getting the error
The error clearly says that the file D:\cacert.pem doesn't exist. Have you created the file as per the instructions?
Hi @amittendulkar, I did exactly as you directed and yet I'm still getting the error
The error clearly says that the file D:\cacert.pem doesn't exist. Have you created the file as per the instructions?
I created the file as per instructions. Here is the screenshot
But since I was stuck there long and couldn't find a way out hence I executed these steps so I asked if it'd be safe to execute them on company laptop?
I see you are trying to make this work for Playwright with Javascript. While I had used the Playwright with Python. I am not sure whether additional steps are required for the npm init
to work.
Can you try the instructions for Playwright with Python (playwright install
command)?
I did try that. It still failed. Hence I tried these steps and it worked. But I was concerned that these following steps would not cause any issue on company laptop.
On top of above cacert.pem made ready, you need to do the below to make playwright to install browsers without errors. `npm config set strict-ssl=false
npm config set registry http://registry.npmjs.org/
npm config set cafile /path/to/your/cert.pem
set NODE_TLS_REJECT_UNAUTHORIZED=0`
Got to resolve this in VM with firewall protection. With Zscaler, if issues exists, please update policy in it and rerun the above.
@ResiakA, have you stored the certificate files at d:? What are their names and paths? Accordingly the file path against the
gc
command will change.
hello
You need to do the following,
- Visit https://playwright.azureedge.net and download the complete certificate chain
- Let's assume your certificates are stored as root.crt, child1.crt, child2.crt, ... , childN.crt etc. at D:\
- Now create an empty file say D:\cacert.pem and execute the below commands in Powershell,
gc d:\root.crt | ac d:\cacert.pem gc d:\child1.crt | ac d:\cacert.pem gc d:\child2.crt | ac d:\cacert.pem ... gc d:\childN.crt | ac d:\cacert.pem
- Now set the NODE_EXTRA_CA_CERTS variable as
set NODE_EXTRA_CA_CERTS=D:\caert.pem
on command line (or$env:NODE_EXTRA_CA_CERTS = 'D:\caert.pem'
in Powershell).- Now your
playwright install
command should work properly.How do you download the "complete certificate chain"? Export... button only exports 1 crt file.
@amittendulkar,
hello while installing the playwright iam getting the errors for downloading the browsers, so please anyone help me for this,
Downloading Chromium 125.0.6422.26 (playwright build v1117) from https://playwright-akamai.azureedge.net/builds/chromium/1117/chromium-win64.zip Error: unable to verify the first certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34) at TLSSocket.emit (node:events:519:28) at TLSSocket._finishInit (node:_tls_wrap:1085:8) at ssl.onhandshakedone (node:_tls_wrap:871:12) { code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
iam getting this error, kindly help me for solve this issue
You need to do the following,
- Visit https://playwright.azureedge.net and download the complete certificate chain
- Let's assume your certificates are stored as root.crt, child1.crt, child2.crt, ... , childN.crt etc. at D:\
- Now create an empty file say D:\cacert.pem and execute the below commands in Powershell,
gc d:\root.crt | ac d:\cacert.pem gc d:\child1.crt | ac d:\cacert.pem gc d:\child2.crt | ac d:\cacert.pem ... gc d:\childN.crt | ac d:\cacert.pem
- Now set the NODE_EXTRA_CA_CERTS variable as
set NODE_EXTRA_CA_CERTS=D:\caert.pem
on command line (or$env:NODE_EXTRA_CA_CERTS = 'D:\caert.pem'
in Powershell).- Now your
playwright install
command should work properly.How do you download the "complete certificate chain"? Export... button only exports 1 crt file.
You need to download each certificate in the certificate chain manually and import into the pem file.
You need to do the following,
- Visit https://playwright.azureedge.net and download the complete certificate chain
- Let's assume your certificates are stored as root.crt, child1.crt, child2.crt, ... , childN.crt etc. at D:\
- Now create an empty file say D:\cacert.pem and execute the below commands in Powershell,
gc d:\root.crt | ac d:\cacert.pem gc d:\child1.crt | ac d:\cacert.pem gc d:\child2.crt | ac d:\cacert.pem ... gc d:\childN.crt | ac d:\cacert.pem
- Now set the NODE_EXTRA_CA_CERTS variable as
set NODE_EXTRA_CA_CERTS=D:\caert.pem
on command line (or$env:NODE_EXTRA_CA_CERTS = 'D:\caert.pem'
in Powershell).- Now your
playwright install
command should work properly.How do you download the "complete certificate chain"? Export... button only exports 1 crt file.
You need to download each certificate in the certificate chain manually and import into the pem file.
@amittendulkar hello amit i have downloded the certificate and i have only C drive and i dont have any other drives so i created a folder in C drive and because it is not allowing me to create directly pem file so i created a folder and then created a cacert.pem file and i went to path then powershell and ran your command but iam getting error and also i tried in normal mode and administrator mode but getting an error of commandNotFound exception and powershell not allowed me to take screenshot otherwise i would have sent it, so better you can communicate with me on my whatsapp 8088261941 so that we can solve this issue more quickly, thanks
to be honest, I just end up running set NODE_TLS_REJECT_UNAUTHORIZED=0
Hi Amittendulkar and others, I created cacert.pem as described, but still get the exact same error when trying to install playwright. I only get one cert at https://playwright.azureedge.net/. The cert is from Digital Guardian as shown in below screen shots. I tried the set NODE_TLS_REJECT_UNAUTHORIZED=0 suggestion from AR-George, but that also gave the same playwright install error. The npm commands in millenial94 suggestions were not recognized. Any help anyone could offer would be greatly appreciated. Thanks.
Hi Amittendulkar and others, I created cacert.pem as described, but still get the exact same error when trying to install playwright. I only get one cert at https://playwright.azureedge.net/. The cert is from Digital Guardian as shown in below screen shots. I tried the set NODE_TLS_REJECT_UNAUTHORIZED=0 suggestion from AR-George, but that also gave the same playwright install error. The npm commands in millenial94 suggestions were not recognized. Any help anyone could offer would be greatly appreciated. Thanks.
You should see the certificate chain in the "details" tab of the screenshot you have posted (you have given the screenshot of the "General" tab). Download and import each certificate in the chain.
There is no chain in the details. It is just the one cert from Digital Guardian.
I installed node and tried the npm commands from millenial94 and still got the same error.
I tried installing Chromium 126.0.6478.62 using Chocolatey v2.3.0, but this did not work for playwright.
I tried installing the certificate, but still same error. There are a dozen certificate stores so do not know which one would work if at all.
This is what the cacert.pem file looks like:
There is no chain in the details. It is just the one cert from Digital Guardian.
Click each node in the certificate hierarchy and then export. I think you have 2 certificates in the chain (first one being "Digital Guardian, Inc.").
I created another cacert.pem file with two certificates in it, but still get the same error:
The cacert.pem file looks like this now:
File in D: drive
I do not know what else to try with the certificate. Is there a way to bypass the certificate or manually install the https://playwright.azureedge.net/builds/chromium/1117/chromium-win64.zip file? Thanks for all your help on this issue Amit.
I suggest not to create a blank cacert.pem file in D:. Append your downloaded certificates to an existing certificate pem file referred by Python. In my case,
> python -m certifi
D:\venv\amazon\lib\site-packages\certifi\cacert.pem
So I appended the downloaded certificates to the above file.
gc d:\root.crt | ac D:\venv\amazon\lib\site-packages\certifi\cacert.pem
gc d:\child1.crt | ac D:\venv\amazon\lib\site-packages\certifi\cacert.pem
gc d:\child2.crt | ac D:\venv\amazon\lib\site-packages\certifi\cacert.pem
...
gc d:\childN.crt | ac D:\venv\amazon\lib\site-packages\certifi\cacert.pem
Now set Node.js to find the above file,
$env:NODE_EXTRA_CA_CERTS='D:\venv\amazon\lib\site-packages\certifi\cacert.pem'
Now the playwright install should work (at least I don't have any more tips than above as I am not actively using playwright at the moment).
Also refer to https://github.com/microsoft/playwright/issues/19622#issuecomment-1435517631
The above instructions might help you.
I added the certifi module with pip install certifi and set the path to the cacert.pem file it created:
I appendeded the two Digital Guardian certs to the new cacert.pem file, but still got the same error:
I tried running the npm commands in the #19622 comment, but still got the same error:
"playwright install" command fails with UNABLE_TO_GET_ISSUER_CERT_LOCALLY error
I am using Windows 11 with Python 3.8.10
Here is the trace.
I found out that this error comes because my company has installed Zscaler on my laptop which is presenting its own certificate when browsed the Microsoft CDN website,
I imported the root and intermediate certificates to the cacert.pem file as mentioned in the below URL. https://community.zscaler.com/t/installing-tls-ssl-root-certificates-to-non-standard-environments/7261
Specifically I used the below commands,
Still I got the same errors.
Then I referred to https://playwright.dev/docs/browsers#install-behind-a-firewall-or-a-proxy to understand that I might need to set a proxy.
By logging in to ip.zscaler.net I got the following details,
When I set the proxy like this and tried installing the browsers, I got the below error,
Any pointers?