https: support rejectUnauthorized for unix sockets

This commit allows self signed certificates to work with
unix sockets by forwarding the rejectUnauthorized option.

Backport-PR-URL: https://github.com/nodejs/node/pull/14415
Fixes: https://github.com/nodejs/node/issues/13470
PR-URL: https://github.com/nodejs/node/pull/13505
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
cjihrig authored and Myles Borins committed 2017-07-30 23:11:12 -05:00
1 parent f66f09f5d1
commit 01302989a7
2 files changed
+30 -1

No files matched your search

+2 -1
View File
@@ -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) {
@@ -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
});
}));