Skip to content

Commit 75c84b2

Browse files
skenqbxjasnell
authored andcommitted
test: add test for https agent servername option
PR-URL: nodejs/node-v0.x-archive#9368 Reviewed-By: jasnell - James M Snell <jasnell@gmail.com>
1 parent 16ca077 commit 75c84b2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var common = require('../common');
2+
var assert = require('assert');
3+
4+
if (!common.hasCrypto) {
5+
console.log('1..0 # Skipped: missing crypto');
6+
process.exit();
7+
}
8+
9+
var https = require('https');
10+
var fs = require('fs');
11+
12+
var options = {
13+
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
14+
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'),
15+
ca: fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem')
16+
};
17+
18+
19+
var server = https.Server(options, function(req, res) {
20+
res.writeHead(200);
21+
res.end('hello world\n');
22+
});
23+
24+
25+
server.listen(common.PORT, function() {
26+
https.get({
27+
path: '/',
28+
port: common.PORT,
29+
rejectUnauthorized: true,
30+
servername: 'agent1',
31+
ca: options.ca
32+
}, function(res) {
33+
res.resume();
34+
console.log(res.statusCode);
35+
server.close();
36+
}).on('error', function(e) {
37+
console.log(e.message);
38+
process.exit(1);
39+
});
40+
});

0 commit comments

Comments
 (0)