Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support serving over HTTPS #29

Open
shuffle2 opened this issue Apr 22, 2017 · 1 comment
Open

Support serving over HTTPS #29

shuffle2 opened this issue Apr 22, 2017 · 1 comment

Comments

@shuffle2
Copy link

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.

@tacerus
Copy link

tacerus commented Jun 29, 2022

Not a JS expert either, but great patch for me, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants