microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

[Question]: How to fix failed to download browser EPROTO BC5A0000:error:0A00010B:SSL #2552

Closed surfmuggle closed 1 year ago

surfmuggle commented 1 year ago

Your question

The installation for JavaScript did work. But for dotnet it failed.

Installation for dotnet gives these steps for NUnit

  1. run dotnet new nunit -n PlaywrightTests and cd PlaywrightTests - this worked ๐Ÿ‘
  2. run dotnet add package Microsoft.Playwright.NUnit - this worked ๐Ÿ‘
  3. run dotnet build - this worked ๐Ÿ‘ Build succeeded. 0 Warning(s) 0 Error(s)
  4. run pwsh bin/Debug/net7.0/playwright.ps1 install - this failed ๐Ÿ‘Ž

Error Screen

image

Error Message

Error: write EPROTO 30580000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:
    c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:355:

    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) 
     {  errno: -4046,    code: 'EPROTO',    syscall: 'write' }

Downloading Chromium 112.0.5615.29 (playwright build v1055) from 
https://playwright-akamai.azureedge.net/builds/chromium/1055/chromium-win64.zip

Error: write EPROTO 58580000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:
    c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:355:

    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) 

  { errno: -4046, code: 'EPROTO',  syscall: 'write' }

Downloading Chromium 112.0.5615.29 (playwright build v1055) from 
https://playwright-verizon.azureedge.net/builds/chromium/1055/chromium-win64.zip

Error: write EPROTO 7C5A0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number: 
     c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:355:

    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)

   { errno: -4046,  code: 'EPROTO',  syscall: 'write' }

Failed to install browsers
Error: Failed to download Chromium 112.0.5615.29 (playwright build v1055), caused by
Error: Download failure, code=1
    at ChildProcess.<anonymous> 
     (C:\dev\playwright\PlayNet\PlaywrightTests\bin\Debug\net7.0
           \.playwright\package\lib\server\registry\browserFetcher.js:95:16)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)

Question and Possible causes

I am behind a corporate proxy.

Error: 
   write EPROTO 30580000:
         error:
                  0A00010B:
                        SSL routines:ssl3_get_record:wrong version number:
                             c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:355:

What else have i tried?

The Installation for JavaSript works

C:\dev\playwright\PlayLatest>npm init playwright@latest
Need to install the following packages:
  create-playwright@1.17.127
Ok to proceed? (y) y
Getting started with writing end-to-end tests with Playwright:
Initializing project in '.'
โˆš Do you want to use TypeScript or JavaScript? ยท JavaScript
โˆš Where to put your end-to-end tests? ยท tests
โˆš Add a GitHub Actions workflow? (y/N) ยท false
โˆš Install Playwright browsers (can be done manually via 'npx playwright install')? (Y/n) ยท true
Initializing NPM project (npm init -y)โ€ฆ
Wrote to C:\dev\playwright\PlayLatest\package.json:

Installing Playwright Test (npm install --save-dev @playwright/test)โ€ฆ
....
added 4 packages in 7s
Downloading browsers (npx playwright install)โ€ฆ
Downloading Chromium 112.0.5615.29 (playwright build v1055) from 
https://playwright.azureedge.net/builds/chromium/1055/chromium-win64.zip
113 Mb [====================] 100% 0.0s
Chromium 112.0.5615.29 (playwright build v1055) downloaded to 
      C:\Users\foo\AppData\Local\ms-playwright\chromium-1055
Downloading Firefox 111.0 (playwright build v1391) from 
       https://playwright.azureedge.net/builds/firefox/1391/firefox-win64.zip
79.7 Mb [====================] 100% 0.0s
Firefox 111.0 (playwright build v1391) downloaded to  
        C:\Users\foo\AppData\Local\ms-playwright\firefox-1391
Downloading Webkit 16.4 (playwright build v1811) from 
     https://playwright.azureedge.net/builds/webkit/1811/webkit-win64.zip
45.7 Mb [====================] 100% 0.0s
Webkit 16.4 (playwright build v1811) downloaded to 
   C:\Users\foo\AppData\Local\ms-playwright\webkit-1811
Writing playwright.config.js.
Writing tests\example.spec.js.
Writing tests-examples\demo-todo-app.spec.js.
Writing package.json.
โœ” Success! Created a Playwright Test project at C:\dev\playwright\PlayLatest
mxschmitt commented 1 year ago

Have you seen this guide which is about installing browsers when using proxies?

-> I'd try to set the NODE_EXTRA_CA_CERTS env var. Maybe your default Node already sets this somehow, maybe via a global npmrc or something like that and our Node inside the .NET package does not consider this option.

surfmuggle commented 1 year ago

I tried the follwing

  1. from cmd.exe i started the cert-manager gui by typing Certmgr.msc
  2. inside Certmgr.msc i picked the folder trustworthy root certificates and opened the subfolder Certificates
  3. i exported one of our company root certificates to this path and file: C:\Users\Public\CertOfOurCompany\One-CA-ROOT-10.cer
  4. on cmd.exe i ran set NODE_EXTRA_CA_CERTS="C:\Users\Public\CertOfOurCompany\One-CA-ROOT-10.cer" in the docs is said to use set NODE_EXTRA_CA_CERTS="C:\certs\root.crt" but to my knowledege the files *.crt and *.cer are of the same type.
  5. i ran step 4 from above again C:\dev\playwright\PlayNet\PlaywrightTests>pwsh bin/Debug/net7.0/playwright.ps1 install and got this error:
Warning: Ignoring extra certs from `"C:\Users\Public\CertOfOurCompany\One-CA-ROOT-10.cer"`, 
load failed: error:8000007B:system library::Unknown error
mxschmitt commented 1 year ago

Looks like the file path is double quoted: https://github.com/nodejs/node/blob/2e0152ccf1a895962991ae3512a941454e68ac71/src/crypto/crypto_context.cc#L1374

Try to remove the double quotes or set the env var via PowerShell:

$Env:NODE_EXTRA_CA_CERTS="C:\Users\Public\CertOfOurCompany\One-CA-ROOT-10.cer"
mxschmitt commented 1 year ago

Since this is unlikely an issue with Playwright and more like a configuration issue of your system to make Node.js (which Playwright uses under the hood) work with the custom proxies, we unfortunately cannot assist on that. If you have any findings, I recommend posting them into this issue, so future users who encounter this could use it as a reference to workaround / fix this issue.

Thanks for your understanding.