• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const fixtures = require('../common/fixtures');
4
5if (!common.hasCrypto)
6  common.skip('missing crypto');
7
8const https = require('https');
9const assert = require('assert');
10
11{
12  const server = https.createServer({
13    cert: fixtures.readKey('agent1-cert.pem'),
14    key: fixtures.readKey('agent1-key.pem'),
15  }, common.mustCall((req, res) => {
16    server.close();
17    res.end();
18  }));
19
20  server.listen(0, 'localhost', common.mustCall(() => {
21    const port = server.address().port;
22    const req = https.get({
23      host: 'localhost',
24      pathname: '/',
25      port,
26      family: 4,
27      localPort: common.PORT,
28      rejectUnauthorized: false,
29    }, common.mustCall(() => {
30      assert.strictEqual(req.socket.localPort, common.PORT);
31      assert.strictEqual(req.socket.remotePort, port);
32    }));
33  }));
34}
35