Here is the client code I am working with:var options = { hostname: "my host", port: 8080, path: '/', method: 'GET', key: fs.readFileSync('clients key'), cert: fs.readFileSync('client cert'), ca: fs.readFileSync('CA cert'), rejectUnauthorized: false, }; // code to get current time var req = https.request(options, function(res) { res.on('data', function(data) { process.stdout.write(data); }); }); // code to get end time and thus calculate total time of transaction. But end == start time! req.end(); Here is the server codevar options = { key: fs.readFileSync('server key'), cert: fs.readFileSync('server cert'), ca: fs.readFileSync('CA cert'), requestCert: true, rejectUnauthorized: false }; https.createServer(options, function (req, res) { res.writeHead(200); res.end("Hello client" + "\n"); }).listen(8080, "host"); So right now I can successfully make a GET request from my client to my HTTPS server (haven't actually added in a resource to retrieve yet). The thing is, when I print out the time for the client to make the http.request() and the time it finishes (both in ms), they are the same! The connection between my client and server has an inherent baseline 5ms delay which clearly shows something is wrong, as my start time == my end time (where as my end time should be ~10ms more than my start time).My first guess is that I need to manually perform a TCP handshake and/or a TLS handshake, although I assumed that would be done under the covers by http.request(). Am I missing something here? Do I need to be doing something else to perform a handshake? Thanks!
Submitted November 27, 2019 at 06:56PM by michaelrichard70
No comments:
Post a Comment