Your code is completely functional. I tested it in my local host. I think the problem is with your key generation. Try creating the keys again and starting your server. I hope this works.
: , , localhost. - IDE (, codio.com, koding.com, cloud9.com ..). , SSL , Verysign.
.
1: "key.pem" .
$ openssl genrsa 1024 > key.pem
2: SSL "key-cert.pem" .
$ openssl req -x509 -new -key key.pem > key-cert.pem
3: 'server.js .
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('key-cert.pem')
};
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8001);
4: , .
$ node server.js
5: URL 'https://localhost:8001' , "hello world" .