server.listen(0, () => { const agent = https.Agent({ keepAlive: true, }); let client; let renegs = 0; const options = { rejectUnauthorized: false, agent, }; const { port } = server.address(); https.get(`https://localhost:${port}/`, options, (res) => { client = res.socket; client.on('close', (hadErr) => { assert.strictEqual(hadErr, false); assert.strictEqual(renegs, tls.CLIENT_RENEG_LIMIT + 1); server.close(); process.nextTick(next); }); client.on('error', (err) => { console.log('CLIENT ERR', err); throw err; }); spam(); // simulate renegotiation attack function spam() { client.renegotiate({}, (err) => { assert.ifError(err); assert.ok(renegs <= tls.CLIENT_RENEG_LIMIT); setImmediate(spam); }); renegs++; } }); });
'use strict'; const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); const assert = require('assert'); const https = require('https'); assert.ok(https.Agent() instanceof https.Agent);