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

Silently fails with rejectUnauthorized:false #1148

Closed
2 tasks done
bezoerb opened this issue Apr 8, 2020 · 1 comment
Closed
2 tasks done

Silently fails with rejectUnauthorized:false #1148

bezoerb opened this issue Apr 8, 2020 · 1 comment

Comments

@bezoerb
Copy link

bezoerb commented Apr 8, 2020

Describe the bug

  • Node.js version: v13.8.0
  • OS & version: macOS 10.14.6

When i set the rejectUnauthorized request option the script silently fails without error.

Actual behavior

Running this script fails with the TLS error:

const got = require('got');
(async () => {
  try {
    const response = await got('https://fonts.googleapis.com/css?family=Merriweather:300,700,700itali', {
      rejectUnauthorized: true,
    });
    console.log('DONE');
  } catch (error) {
    console.error(error);
  }
})()

->

GotError: unable to verify the first certificate
    at onError (.../got/dist/source/request-as-event-emitter.js:139:29)
    at handleRequest (.../got/dist/source/request-as-event-emitter.js:172:17)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at TLSSocket.onConnectSecure (_tls_wrap.js:1475:34)
    at TLSSocket.emit (events.js:321:20)
    at TLSSocket._finishInit (_tls_wrap.js:918:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:688:12) {
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
  name: 'RequestError'
}

when setting the rejectUnauthorized option to true the script just exits without any output.
This was working as expected in got@9

Expected behavior

The response is returned

Code to reproduce

See above ;)

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.
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