GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — https: use `servername` in agent key · nodejs/node@3213e5f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • https.js
  • test/parallel
    • test-https-agent-sni.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/https.js‎

Copy file name to clipboardExpand all lines: lib/https.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ Agent.prototype.getName = function(options) {
130130
if (options.rejectUnauthorized !== undefined)
131131
name += options.rejectUnauthorized;
132132

133+
name += ':';
134+
if (options.servername && options.servername !== options.host)
135+
name += options.servername;
136+
133137
return name;
134138
};
135139

Collapse file

‎test/parallel/test-https-agent-sni.js‎

Copy file name to clipboard
+52Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
5+
if (!common.hasCrypto) {
6+
console.log('1..0 # Skipped: missing crypto');
7+
return;
8+
}
9+
const https = require('https');
10+
11+
const fs = require('fs');
12+
13+
const options = {
14+
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
15+
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
16+
};
17+
18+
const TOTAL = 4;
19+
var waiting = TOTAL;
20+
21+
const server = https.Server(options, function(req, res) {
22+
if (--waiting === 0) server.close();
23+
24+
res.writeHead(200, {
25+
'x-sni': req.socket.servername
26+
});
27+
res.end('hello world');
28+
});
29+
30+
server.listen(common.PORT, function() {
31+
function expectResponse(id) {
32+
return common.mustCall(function(res) {
33+
res.resume();
34+
assert.equal(res.headers['x-sni'], 'sni.' + id);
35+
});
36+
}
37+
38+
var agent = new https.Agent({
39+
maxSockets: 1
40+
});
41+
for (var j = 0; j < TOTAL; j++) {
42+
https.get({
43+
agent: agent,
44+
45+
path: '/',
46+
port: common.PORT,
47+
host: '127.0.0.1',
48+
servername: 'sni.' + j,
49+
rejectUnauthorized: false
50+
}, expectResponse(j));
51+
}
52+
});

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.