Skip to content
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

[BUG] Unable to install playwright in apple mac m1 machine - SSL error #16779

Closed
pexa-skumarbadrinath opened this issue Aug 23, 2022 · 12 comments

Comments

@pexa-skumarbadrinath
Copy link

I am unable to install playwright in my apple machbook m1 chip machine. I am getting an SSL error.

  • Playwright Version: NA
  • Operating System: Mac
  • Node.js version: v18.4.0
  • Browser: NA
$ npm init playwright@latest --yes -- --quiet --browser=chromium --browser=firefox --browser=webkit --gha
Getting started with writing end-to-end tests with Playwright:
Initializing project in '.'
Installing Playwright Test (npm install --save-dev @playwright/test)…

up to date, audited 4 packages in 2s

found 0 vulnerabilities
Downloading browsers (npx playwright install chromium firefox webkit)…
Failed to install browsers
Error: Failed to download Chromium 105.0.5195.19 (playwright build v1019), caused by
Error: write EPROTO 80C5480901000000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:908:

    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
Error: Command failed: npx playwright install chromium firefox webkit
    at checkExecSyncError (node:child_process:820:11)
    at execSync (node:child_process:891:15)
@yury-s
Copy link
Member

yury-s commented Aug 23, 2022

@pexa-skumarbadrinath what is you macOS version? Are you running this command from VS Code or in a system terminal?

@pexa-skumarbadrinath
Copy link
Author

pexa-skumarbadrinath commented Aug 23, 2022

@yury-s I tried using both direct terminal install and from vscode.

my mac version is 12.5.1 (21G83) (Monterey)
And my openssl version is

 $ openssl version
OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022)

$ curl --version
curl 7.79.1 (x86_64-apple-darwin21.0) libcurl/7.79.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.45.1
Release-Date: 2021-09-22
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets

@yury-s
Copy link
Member

yury-s commented Aug 23, 2022

I had

$ openssl version
LibreSSL 2.8.3

but after switching to

 openssl version
OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022)

nothing changed, the downloads still work fine. Do you have some custom settings in openssl.cnf (openssl version -d should give you its directory) ?

@pexa-skumarbadrinath
Copy link
Author

There is no custom configuration in the openssl configuration.

This is my openssl configuration.

distinguished_name	= req_distinguished_name
attributes		= req_attributes

[ req_distinguished_name ]
countryName			= Country Name (2 letter code)
countryName_min			= 2
countryName_max			= 2
stateOrProvinceName		= State or Province Name (full name)
localityName			= Locality Name (eg, city)
0.organizationName		= Organization Name (eg, company)
organizationalUnitName		= Organizational Unit Name (eg, section)
commonName			= Common Name (eg, fully qualified host name)
commonName_max			= 64
emailAddress			= Email Address
emailAddress_max		= 64

[ req_attributes ]
challengePassword		= A challenge password
challengePassword_min		= 4
challengePassword_max		= 20

@yury-s
Copy link
Member

yury-s commented Aug 24, 2022

Yeah, theses are defaults. Can you run with DEBUG=pw:install env variable and copy the output here?

@pexa-skumarbadrinath
Copy link
Author

$ DEBUG=pw:install npm install playwright
npm ERR! code 1
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! Downloading Chromium 105.0.5195.19 (playwright build v1019)...
npm ERR! Downloading Chromium 105.0.5195.19 (playwright build v1019)...
npm ERR! Downloading Chromium 105.0.5195.19 (playwright build v1019)...
npm ERR! 2022-08-24T01:10:11.754Z pw:install downloading Chromium 105.0.5195.19 (playwright build v1019) - attempt #1
npm ERR! 2022-08-24T01:10:11.755Z pw:install running download:
npm ERR! 2022-08-24T01:10:11.755Z pw:install -- from url: https://playwright.azureedge.net/builds/chromium/1019/chromium-mac-arm64.zip
npm ERR! 2022-08-24T01:10:11.755Z pw:install -- to location: /var/folders/pv/sfgct_j50ws8sx3tls99b5sw0000gq/T/playwright-download-chromium-mac12-arm64-1019.zip
npm ERR! 2022-08-24T01:10:12.124Z pw:install attempt #1 - ERROR: write EPROTO 8005F00501000000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:908:
npm ERR! 
npm ERR! 2022-08-24T01:10:12.124Z pw:install downloading Chromium 105.0.5195.19 (playwright build v1019) - attempt #2
npm ERR! 2022-08-24T01:10:12.124Z pw:install running download:
npm ERR! 2022-08-24T01:10:12.124Z pw:install -- from url: https://playwright-akamai.azureedge.net/builds/chromium/1019/chromium-mac-arm64.zip
npm ERR! 2022-08-24T01:10:12.124Z pw:install -- to location: /var/folders/pv/sfgct_j50ws8sx3tls99b5sw0000gq/T/playwright-download-chromium-mac12-arm64-1019.zip
npm ERR! 2022-08-24T01:10:12.509Z pw:install attempt #2 - ERROR: write EPROTO 8005F00501000000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:908:
npm ERR! 
npm ERR! 2022-08-24T01:10:12.509Z pw:install downloading Chromium 105.0.5195.19 (playwright build v1019) - attempt #3
npm ERR! 2022-08-24T01:10:12.509Z pw:install running download:
npm ERR! 2022-08-24T01:10:12.509Z pw:install -- from url: https://playwright-verizon.azureedge.net/builds/chromium/1019/chromium-mac-arm64.zip
npm ERR! 2022-08-24T01:10:12.509Z pw:install -- to location: /var/folders/pv/sfgct_j50ws8sx3tls99b5sw0000gq/T/playwright-download-chromium-mac12-arm64-1019.zip
npm ERR! 2022-08-24T01:10:12.722Z pw:install attempt #3 - ERROR: write EPROTO 8005F00501000000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:908:
npm ERR! 
npm ERR! 2022-08-24T01:10:12.723Z pw:install FAILED installation Chromium 105.0.5195.19 (playwright build v1019) with error: Error: write EPROTO 8005F00501000000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:908:

@pexa-skumarbadrinath
Copy link
Author

pexa-skumarbadrinath commented Aug 24, 2022

I am able to do a manual curl to the url. But it is not working when i do it with npm install.

$ curl https://playwright-verizon.azureedge.net/builds/chromium/1019/chromium-mac-arm64.zip --output playwright.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  119M  100  119M    0     0  2861k      0  0:00:42  0:00:42 --:--:-- 3291k

@pexa-skumarbadrinath
Copy link
Author

The error is due to a certificate issue in the server. when trying to understand the certificate usage of server, i ran this command for all three CDN endpoints

$ openssl s_client -showcerts -servername playwright.azureedge.net -connect playwright.azureedge.net:443 2>/dev/null 
CONNECTED(00000006)
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 85 bytes and written 337 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : 0000
    Session-ID: 241100000ABA4A53E2599E47E213E23486AB24FBB62675DB7C834447ADA69844
    Session-ID-ctx: 
    Master-Key: 
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1661807410
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: yes
---

Verizon CDN

 $ openssl s_client -showcerts -servername playwright-verizon.azureedge.net -connect playwright-verizon.azureedge.net:443 2>/dev/null
CONNECTED(00000005)
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 85 bytes and written 345 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : 0000
    Session-ID: 2C0F2ABEC7B99C2B57152AF67202F951DEE5A3030F50424E0A2A838C7CC2CD53
    Session-ID-ctx: 
    Master-Key: 
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1661807491
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: yes
---

Akamai CDN

$ openssl s_client -showcerts -servername playwright-akamai.azureedge.net -connect playwright-akamai.azureedge.net:443 2>/dev/null
CONNECTED(00000006)
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 79 bytes and written 344 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : 0000
    Session-ID: A48D0399475F0858FB2CE130C09E612F967C18FD5FC346904AF8D6F588D79FA4
    Session-ID-ctx: 
    Master-Key: 
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1661806823
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: no
---

The output clearly says Secure Renegotiation IS NOT supported, which is the root cause for this issue.

To overcome this issue, I have to create a temp openssl conf (as suggested in this stackoverflow answer - https://stackoverflow.com/a/72245418/1559397 ) to bypass the renegotiation. Post that change, I got the below error.

 $ OPENSSL_CONF=/tmp/openssl.cnf DEBUG=pw:install npm install playwright
npm ERR! code 1
npm ERR! path node_modules/playwright
npm ERR! command failed
npm ERR! command sh -c -- node install.js
npm ERR! Downloading Chromium 105.0.5195.19 (playwright build v1019)...
npm ERR! Downloading Chromium 105.0.5195.19 (playwright build v1019)...
npm ERR! Downloading Chromium 105.0.5195.19 (playwright build v1019)...
npm ERR! 2022-08-29T20:47:12.157Z pw:install downloading Chromium 105.0.5195.19 (playwright build v1019) - attempt #1
npm ERR! 2022-08-29T20:47:12.158Z pw:install running download:
npm ERR! 2022-08-29T20:47:12.158Z pw:install -- from url: https://playwright.azureedge.net/builds/chromium/1019/chromium-mac-arm64.zip
npm ERR! 2022-08-29T20:47:12.158Z pw:install -- to location: /var/folders/pv/sfgct_j50ws8sx3tls99b5sw0000gq/T/playwright-download-chromium-mac12-arm64-1019.zip
npm ERR! 2022-08-29T20:47:12.329Z pw:install attempt #1 - ERROR: self-signed certificate in certificate chain
npm ERR! 2022-08-29T20:47:12.329Z pw:install downloading Chromium 105.0.5195.19 (playwright build v1019) - attempt #2
npm ERR! 2022-08-29T20:47:12.329Z pw:install running download:
npm ERR! 2022-08-29T20:47:12.329Z pw:install -- from url: https://playwright-akamai.azureedge.net/builds/chromium/1019/chromium-mac-arm64.zip
npm ERR! 2022-08-29T20:47:12.329Z pw:install -- to location: /var/folders/pv/sfgct_j50ws8sx3tls99b5sw0000gq/T/playwright-download-chromium-mac12-arm64-1019.zip
npm ERR! 2022-08-29T20:47:12.456Z pw:install attempt #2 - ERROR: self-signed certificate in certificate chain
npm ERR! 2022-08-29T20:47:12.456Z pw:install downloading Chromium 105.0.5195.19 (playwright build v1019) - attempt #3
npm ERR! 2022-08-29T20:47:12.456Z pw:install running download:
npm ERR! 2022-08-29T20:47:12.456Z pw:install -- from url: https://playwright-verizon.azureedge.net/builds/chromium/1019/chromium-mac-arm64.zip
npm ERR! 2022-08-29T20:47:12.456Z pw:install -- to location: /var/folders/pv/sfgct_j50ws8sx3tls99b5sw0000gq/T/playwright-download-chromium-mac12-arm64-1019.zip
npm ERR! 2022-08-29T20:47:12.554Z pw:install attempt #3 - ERROR: self-signed certificate in certificate chain
npm ERR! 2022-08-29T20:47:12.555Z pw:install FAILED installation Chromium 105.0.5195.19 (playwright build v1019) with error: Error: self-signed certificate in certificate chain
....
...
...

npm ERR! Error: Failed to download Chromium 105.0.5195.19 (playwright build v1019), caused by
npm ERR! Error: self-signed certificate in certificate chain
npm ERR!     at TLSSocket.onConnectSecure (node:_tls_wrap:1533:34)
npm ERR!     at TLSSocket.emit (node:events:537:28)
npm ERR!     at TLSSocket._finishInit (node:_tls_wrap:947:8)
npm ERR!     at ssl.onhandshakedone (node:_tls_wrap:728:12)

Then I have to make ssl verify false for nodejs in the process.

DEBUG=pw:install NODE_TLS_REJECT_UNAUTHORIZED='0' npm install playwright

After all these overrides, I was able to install playwright and install the browsers successfully.

@yury-s
Copy link
Member

yury-s commented Aug 29, 2022

This doesn't seem right, we should not disable any ssl checks for the downloads. We should fix the servers if they trigger this problem but we need to be able to reproduce it first, do you run with custom NODE_OPTIONS in your env? What does node -e "console.log(process.versions)" | grep ssl show you?

@pexa-skumarbadrinath
Copy link
Author

@yury-s I don't have custom NODE_OPTIONS in my env and output for the node command is,

$ node -e "console.log(process.versions)" | grep ssl
  openssl: '3.0.3+quic',

@yury-s
Copy link
Member

yury-s commented Aug 30, 2022

@pexa-skumarbadrinath this is exactly same configuration that I have, are you behind a proxy?

@pexa-skumarbadrinath
Copy link
Author

@yury-s Yes. I am behind a proxy and VPN. I have figured out the issue. My proxy is blocking the request and working with my internal IT team to check that out.

I have confirmed the same with my colleagues too. We can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants