Skip to content

Support serving over HTTPS #29

Description

@shuffle2

I am new to node.js (so probably something better should be done), but I'm using the following on my server:

diff --git a/src/app.js b/src/app.js
index a37291f..4a14eef 100644
--- a/src/app.js
+++ b/src/app.js
@@ -30,6 +30,8 @@ const PGP = require('./service/pgp');
 const PublicKey = require('./service/public-key');
 const HKP = require('./route/hkp');
 const REST = require('./route/rest');
+const fs = require('fs');
+const https = require('https');
 
 let mongo, email, pgp, publicKey, hkp, rest;
 
@@ -123,7 +125,12 @@ function injectDependencies() {
 if (!global.testing) { // don't automatically start server in tests
   co(function *() {
     let app = yield init();
-    app.listen(config.server.port);
+    let https_options = {
+      key: fs.readFileSync('privkey.pem'),
+      cert: fs.readFileSync('cert.pem')
+    };
+    https.createServer(https_options, app.callback()).listen(config.server.port);
     log.info('app', 'Ready to rock! Listening on http://localhost:' + config.server.port);
   }).catch(err => log.error('app', 'Initialization failed!', err));
 }

This is because keyserver is running on a different machine than the reverse proxy (which has the HTTPS server actually talking to the browser client), and I wish to avoid the "https added and removed here" problem.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions