Skip to content

Commit

Permalink
Add SSL for localhost so geolocation can be tested more easily - ref #66
Browse files Browse the repository at this point in the history
  • Loading branch information
macintoshhelper committed May 7, 2017
1 parent 4f2f32f commit 869f29b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"postinstall": "node gulpfile.js",
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
"precommit-msg": "echo 'Pre-commit checks...' && exit 0",
"init": "bash scripts/init.sh",
"dev": "./node_modules/.bin/nodemon --ext js,scss,hbs --ignore public/ src/start.js"
},
"pre-commit": [
Expand Down
8 changes: 8 additions & 0 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
openssl genrsa -out key.pem 2048
openssl req -new -key key.pem -out csr.pem -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost"
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
rm csr.pem
mkdir keys
mv cert.pem keys/cert.pem
mv key.pem keys/key.pem
echo 'keys/' >> .gitignore
7 changes: 7 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs');
const hapi = require('hapi');
const vision = require('vision');
const routes = require('./routes/index.js');
Expand All @@ -7,8 +8,14 @@ const jwt = require('hapi-auth-jwt2');

const server = new hapi.Server();

const tls = {
key: fs.readFileSync('./keys/key.pem'),
cert: fs.readFileSync('./keys/cert.pem'),
};

server.connection({
port: process.env.PORT || 3000,
tls,
});

const jwtValidate = (decoded, request, callback) => {
Expand Down

0 comments on commit 869f29b

Please sign in to comment.