1 var common = require('../common');
2 var assert = require('assert');
4 if (!common.hasCrypto) {
5 console.log('1..0 # Skipped: missing crypto');
8 var https = require('https');
10 var url = require('url');
11 var fs = require('fs');
16 key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
17 cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
20 var testURL = url.parse('https://localhost:' + common.PORT);
21 testURL.rejectUnauthorized = false;
23 function check(request) {
24 // assert that I'm https
25 assert.ok(request.socket._secureEstablished);
28 var server = https.createServer(httpsOptions, function(request, response) {
29 // run the check function
30 check.call(this, request, response);
31 response.writeHead(200, {});
36 server.listen(common.PORT, function() {
38 var clientRequest = https.request(testURL);
39 // since there is a little magic with the agent
40 // make sure that the request uses the https.Agent
41 assert.ok(clientRequest.agent instanceof https.Agent);