serviejs / popsicle

Simple HTTP requests for node and the browser
MIT License
246 stars 19 forks source link

Mimic strictSSL config found in npm:Request ? #108

Closed markbjerke closed 3 years ago

markbjerke commented 7 years ago

We have a dev server that uses a self signed certificate, there is also some bits passed to indicate our TLS handshake is out of spec. This works with the Request package but not with Popsicle. I'd like to use Popsicle for servers with certificate issues.

How can I pass config through to the transport when I'm using NodeJS to allow a connection ?

(getting ECONNREST)

blakeembrey commented 7 years ago

You can use rejectUnauthorized: false from https://github.com/blakeembrey/popsicle#built-in-transports. Let me know if that's what you're after!

markbjerke commented 7 years ago

That helped but you need to pass secureOptions through for the Node transport. This will solve an issue with TLS v 1.2 backwards compatibility. In our shop we have servers running older TLS versions, the client handshake fails without sending require('options').SSL_OP_NO_TLSv1_2 through to the transport:

I added this to the Popsicle code but the connection still fails:

if (_isDefined(options.strictSSL)) { options.transport = popsicle.createTransport({ rejectUnauthorized: !options.strictSSL ,secureOptions: constants.SSL_OP_NO_TLSv1_2 }); }

blakeembrey commented 3 years ago

Closing this out as it's been added as a configuration option in https://github.com/serviejs/popsicle-transport-http going forward.