Unable to setup https in express.js

I'm pretty much following this tutorial (all other tutorials I found look the same)

http://www.hacksparrow.com/express-js-https.html

My code is as follows:

// dependencies
var express = require('express')
  , https = require('https')
  , fs = require('fs');

var privateKey = fs.readFileSync('./ssl/rp-key.pem').toString();
var certificate = fs.readFileSync('./ssl/rp-cert.pem').toString();

var app = express.createServer({
  key : privateKey
, cert : certificate
});

...

// start server
https.createServer(app).listen(app.get('port'), function(){
  console.log("Express server listening on port " + app.get('port'));
});

The app starts fine after sudo node app

Express server listening on port 443

Now when I curl

curl https://localhost/

I get

curl: (35) Unknown SSL protocol error in connection to localhost:443

Any ideas?

Since Express 3.x, which is now being published via npm, the "app()"-Application Function changed. There is an migration info on https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x . None of the express 2.x SSL tutorials will work anymore. The correct Code for express 3.x is:

// dependencies
var express = require('express')
  , https = require('https')
  , fs = require('fs');

var privateKey = fs.readFileSync('./ssl/rp-key.pem').toString();
var certificate = fs.readFileSync('./ssl/rp-cert.pem').toString();

var options = {
  key : privateKey
, cert : certificate
}
var app = express();

...

// start server
https.createServer(options,app).listen(app.get('port'), function(){
  console.log("Express server listening on port " + app.get('port'));
});