Skip to content

Commit c4cbd99

Browse files
cjihrigaddaleax
authored andcommitted
https: support rejectUnauthorized for unix sockets
This commit allows self signed certificates to work with unix sockets by forwarding the rejectUnauthorized option. Fixes: #13470 PR-URL: #13505 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]>
1 parent 4d27930 commit c4cbd99

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

lib/_http_client.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ function ClientRequest(options, cb) {
247247
this.shouldKeepAlive = false;
248248
var optionsPath = {
249249
path: this.socketPath,
250-
timeout: this.timeout
250+
timeout: this.timeout,
251+
rejectUnauthorized: !!options.rejectUnauthorized
251252
};
252253
newSocket = this.agent.createConnection(optionsPath, oncreate);
253254
if (newSocket && !called) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!common.hasCrypto) {
5+
common.skip('missing crypto');
6+
return;
7+
}
8+
9+
common.refreshTmpDir();
10+
11+
const fs = require('fs');
12+
const https = require('https');
13+
const options = {
14+
cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'),
15+
key: fs.readFileSync(common.fixturesDir + '/test_key.pem')
16+
};
17+
18+
const server = https.createServer(options, common.mustCall((req, res) => {
19+
res.end('bye\n');
20+
server.close();
21+
}));
22+
23+
server.listen(common.PIPE, common.mustCall(() => {
24+
https.get({
25+
socketPath: common.PIPE,
26+
rejectUnauthorized: false
27+
});
28+
}));

0 commit comments

Comments
 (0)