| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -143,6 +143,10 @@ Agent.prototype.getName = function getName(options) { | |||
| 143 | 143 | if (options.servername && options.servername !== options.host) | |
| 144 | 144 | name += options.servername; | |
| 145 | 145 | ||
| 146 | + name += ':'; | ||
| 147 | + if (options.secureProtocol) | ||
| 148 | + name += options.secureProtocol; | ||
| 149 | + | ||
| 146 | 150 | return name; | |
| 147 | 151 | }; | |
| 148 | 152 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ const agent = new https.Agent(); | |||
| 14 | 14 | // empty options | |
| 15 | 15 | assert.strictEqual( | |
| 16 | 16 | agent.getName({}), | |
| 17 | - 'localhost:::::::::' | ||
| 17 | + 'localhost::::::::::' | ||
| 18 | 18 | ); | |
| 19 | 19 | ||
| 20 | 20 | // pass all options arguments | |
@@ -33,5 +33,5 @@ const options = { | |||
| 33 | 33 | ||
| 34 | 34 | assert.strictEqual( | |
| 35 | 35 | agent.getName(options), | |
| 36 | - '0.0.0.0:443:192.168.1.1:ca:cert:ciphers:key:pfx:false:localhost' | ||
| 36 | + '0.0.0.0:443:192.168.1.1:ca:cert:ciphers:key:pfx:false:localhost:' | ||
| 37 | 37 | ); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,60 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const assert = require('assert'); | ||
| 3 | + const common = require('../common'); | ||
| 4 | + | ||
| 5 | + if (!common.hasCrypto) { | ||
| 6 | + common.skip('missing crypto'); | ||
| 7 | + return; | ||
| 8 | + } | ||
| 9 | + | ||
| 10 | + const https = require('https'); | ||
| 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 | + ca: fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem') | ||
| 17 | + }; | ||
| 18 | + | ||
| 19 | + const server = https.Server(options, function(req, res) { | ||
| 20 | + res.writeHead(200); | ||
| 21 | + res.end('hello world\n'); | ||
| 22 | + }); | ||
| 23 | + | ||
| 24 | + server.listen(0, common.mustCall(function() { | ||
| 25 | + const port = this.address().port; | ||
| 26 | + const globalAgent = https.globalAgent; | ||
| 27 | + globalAgent.keepAlive = true; | ||
| 28 | + https.get({ | ||
| 29 | + path: '/', | ||
| 30 | + port: port, | ||
| 31 | + ca: options.ca, | ||
| 32 | + rejectUnauthorized: true, | ||
| 33 | + servername: 'agent1', | ||
| 34 | + secureProtocol: 'SSLv23_method' | ||
| 35 | + }, common.mustCall(function(res) { | ||
| 36 | + res.resume(); | ||
| 37 | + globalAgent.once('free', common.mustCall(function() { | ||
| 38 | + https.get({ | ||
| 39 | + path: '/', | ||
| 40 | + port: port, | ||
| 41 | + ca: options.ca, | ||
| 42 | + rejectUnauthorized: true, | ||
| 43 | + servername: 'agent1', | ||
| 44 | + secureProtocol: 'TLSv1_method' | ||
| 45 | + }, common.mustCall(function(res) { | ||
| 46 | + res.resume(); | ||
| 47 | + globalAgent.once('free', common.mustCall(function() { | ||
| 48 | + // Verify that two keep-alived connections are created | ||
| 49 | + // due to the different secureProtocol settings: | ||
| 50 | + const keys = Object.keys(globalAgent.freeSockets); | ||
| 51 | + assert.strictEqual(keys.length, 2); | ||
| 52 | + assert.ok(keys[0].includes(':SSLv23_method')); | ||
| 53 | + assert.ok(keys[1].includes(':TLSv1_method')); | ||
| 54 | + globalAgent.destroy(); | ||
| 55 | + server.close(); | ||
| 56 | + })); | ||
| 57 | + })); | ||
| 58 | + })); | ||
| 59 | + })); | ||
| 60 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments