Amio.io
Amio.io

Reputation: 21585

How to enter path to tls

In NodeJs I am able to connect to another server over TLS. What I am missing is how to enter path. I can enter host only.

var tls = require('tls');
var fs = require('fs');

var options = {
   key  : fs.readFileSync('private.key'),
   cert : fs.readFileSync('public.cert')
};

var client = tls.connect(8000, 'localhost', options, function () {
   console.log(client.authorized ? 'Authorized' : 'Not authorized');
});

If I do tls.connect(8000, 'localhost/my_path', ...) it's resolving to localhost/my_path:8000 which is wrong of course.

How to enter path elements?

Upvotes: 0

Views: 288

Answers (1)

robertklep
robertklep

Reputation: 203514

TLS is "merely" a transport layer, on top of which other protocols can be implemented. One is HTTPS.

Since it looks like you want to make HTTPS requests, you'd want to use https.get() instead of using the tls module.

The path parameter of tls.connect() isn't analogous to the path of a URL, it's used to connect to a TLS server through a Unix domain socket (which is represented on the system by a file, which is what the path should point at).

Upvotes: 1

Related Questions