Rayrun
← Back to Discord Forum

how to skip SELF_SIGNED_CERT_IN_CHAIN validation error

I am using "@playwright/test": "^1.36.2"; Attached is a method that I call in a test which fails on fetch call throwing following error

at TLSSocket.onConnectSecure (node:_tls_wrap:1540:34)
   at TLSSocket.emit (node:events:513:28)
   at TLSSocket._finishInit (node:_tls_wrap:959:8)
   at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:743:12)
   at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17); Outer Message: fetch failed``` 
Same fetch call from postman works as I have the cert installed in my machine. Tried to ignorehttpsError, which didn't help. Attached is my playwright config.
my test spec looks like this   ```test('Send and Recieve Notifications', async ({ page }) => {
 const publicationFixture = new PublicationFixture();
 const token = await new IdentityClient().getToken();
 console.log(token)
 })``` 
Appreciate your suggestion on this, thank you
image.png
image.png

This thread is trying to answer question "How can I resolve the 'SELF_SIGNED_CERT_IN_CHAIN' error in my '@playwright/test' package?"

1 reply

Export the cert from your machine into PEM file, then set an environment variable named NODE_EXTRA_CA_CERTS with the file path (on your machine or the env file) https://nodejs.org/api/cli.html#node_extra_ca_certsfile

Answer

Fixing 'self_signed_cert_in_chain' Error in '@playwright/test'

If you're encountering a 'self_signed_cert_in_chain' error with your '@playwright/test' package, here's how you can tackle it:

Set Custom Root Certificates

If your proxy's requests are intercepted with an untrusted certificate authority (CA), causing the error, you need to set your custom root certificates. Use the NODE_EXTRA_CA_CERTS environment variable before installing the browsers. Here's how you do it in Bash:

export NODE_EXTRA_CA_CERTS="/path/to/cert.pem"

Increase Connection Timeout

Slow network? Increase the connection timeout in milliseconds with the PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT environment variable. Here's an example:

PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT=120000 npx playwright install

Download from Artifact Repository

Playwright downloads browsers from Microsoft's CDN by default. If your company hosts browser binaries in an internal artifact repository, you can configure Playwright to download from there using the PLAYWRIGHT_DOWNLOAD_HOST environment variable.

Check Proxy Settings

If your company uses an internal proxy that blocks direct access to public resources, you can configure Playwright to download browsers via a proxy server by setting HTTPS_PROXY environment variables.

Remember, these steps are specific to the 'self_signed_cert_in_chain' error and may not cover all '@playwright/test' issues. Always refer to the official documentation or seek further assistance for specific problems.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].