https: support rejectUnauthorized for unix sockets

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

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 2017-06-06 15:06:45 -04:00
parent d958bf88b8
commit d0571a926a
2 changed files with 30 additions and 1 deletions

View File

@ -247,7 +247,8 @@ function ClientRequest(options, cb) {
this.shouldKeepAlive = false;
var optionsPath = {
path: this.socketPath,
timeout: this.timeout
timeout: this.timeout,
rejectUnauthorized: !!options.rejectUnauthorized
};
newSocket = this.agent.createConnection(optionsPath, oncreate);
if (newSocket && !called) {

View File

@ -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
});
}));