diff --git a/lib/_http_client.js b/lib/_http_client.js index 22eadfb5584676..4d71ec594743f4 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -135,7 +135,8 @@ function ClientRequest(options, cb) { self.shouldKeepAlive = false; const optionsPath = { path: self.socketPath, - timeout: self.timeout + timeout: self.timeout, + rejectUnauthorized: !!options.rejectUnauthorized }; const newSocket = self.agent.createConnection(optionsPath, oncreate); if (newSocket && !called) { diff --git a/test/parallel/test-https-unix-socket-self-signed.js b/test/parallel/test-https-unix-socket-self-signed.js new file mode 100644 index 00000000000000..f503b84591cad7 --- /dev/null +++ b/test/parallel/test-https-unix-socket-self-signed.js @@ -0,0 +1,28 @@ +'use strict'; +const common = require('../common'); + +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + +common.refreshTmpDir(); + +const fs = require('fs'); +const https = require('https'); +const options = { + cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'), + key: fs.readFileSync(common.fixturesDir + '/test_key.pem') +}; + +const server = https.createServer(options, common.mustCall((req, res) => { + res.end('bye\n'); + server.close(); +})); + +server.listen(common.PIPE, common.mustCall(() => { + https.get({ + socketPath: common.PIPE, + rejectUnauthorized: false + }); +}));