Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Commit

Permalink
add https support
Browse files Browse the repository at this point in the history
  • Loading branch information
andriykuba committed Jan 11, 2014
1 parent 1906f3b commit e77b0aa
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
13 changes: 13 additions & 0 deletions config/key/cert.pem
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE-----
MIIB6DCCAZICCQDBNspGwagyMjANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJV
QTENMAsGA1UECBMES3lpdjENMAsGA1UEBxMES3lpdjENMAsGA1UEChMESG9tZTEU
MBIGA1UECxMLRGV2ZWxvcG1lbnQxDDAKBgNVBAMTA0FrdTEbMBkGCSqGSIb3DQEJ
ARYMYWt1QGhvbWUuY29tMB4XDTE0MDExMTAyMDEwOFoXDTQxMDUyODAyMDEwOFow
ezELMAkGA1UEBhMCVUExDTALBgNVBAgTBEt5aXYxDTALBgNVBAcTBEt5aXYxDTAL
BgNVBAoTBEhvbWUxFDASBgNVBAsTC0RldmVsb3BtZW50MQwwCgYDVQQDEwNBa3Ux
GzAZBgkqhkiG9w0BCQEWDGFrdUBob21lLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sA
MEgCQQDLO4Ou1p+JAJeh+N0ZBxr+0VpEevnfxKNF+X4U3zB0xIvLZF8YJ2eR2Xoe
XAK64tDIacs8QeCAKFRIUHsEanarAgMBAAEwDQYJKoZIhvcNAQEFBQADQQBP6rxT
phfoORMjcWHqGyHY3iIzD/nhlH4Kc/cuxfffKllT+kItsr7CoEgIvAEOSjZ/Nnn7
QRQ8bErNNDbWm3RP
-----END CERTIFICATE-----
9 changes: 9 additions & 0 deletions config/key/key.pem
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBAMs7g67Wn4kAl6H43RkHGv7RWkR6+d/Eo0X5fhTfMHTEi8tkXxgn
Z5HZeh5cArri0MhpyzxB4IAoVEhQewRqdqsCAwEAAQJBALOQvRPQ3BqfpFpfWXMQ
nSCCd0BEa9zzj9N20pi8bsLrhuZw4ucS3V3w+qr4RUw5QbskPW42jAqiChD6ekgq
QCECIQDqMUv7XKhSkFkwiHEscvCii8SGTWJTPmyHqTjmEmeUUQIhAN4oMDIBOdsF
Ox9BIqtJ6TKAXftjHrosdrDmx/0g7Mg7AiAspJsUXpRjsMqfutLAI2UFx1j+NRAy
SCsOLU8AZK/EEQIgXa4sxKlnsEhAaimZaQm94KHo/70IlBFz650l8EQWFUkCIQDT
uU/B0n7TRWhggivgmrT34d/DBbqRK0b+94ZFkpKuZQ==
-----END RSA PRIVATE KEY-----
10 changes: 5 additions & 5 deletions config/public.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"env":{ "env":{
"production":{ "production":{
"app":{ "app":{
"port": 3000, "port": 443,
"host": "127.0.0.1" "host": "127.0.0.1"
}, },
"db":{ "db":{
Expand All @@ -11,7 +11,7 @@
}, },
"development":{ "development":{
"app":{ "app":{
"port": 3000, "port": 443,
"host": "127.0.0.1" "host": "127.0.0.1"
}, },
"db":{ "db":{
Expand All @@ -20,7 +20,7 @@
}, },
"test":{ "test":{
"app":{ "app":{
"port": 3000, "port": 443,
"host": "127.0.0.1" "host": "127.0.0.1"
}, },
"db":{ "db":{
Expand All @@ -35,8 +35,8 @@
"debitoor":{ "debitoor":{
"authorizationURL": "https://app.debitoor.com/login/oauth2/authorize", "authorizationURL": "https://app.debitoor.com/login/oauth2/authorize",
"tokenURL": "https://app.debitoor.com/login/oauth2/access_token", "tokenURL": "https://app.debitoor.com/login/oauth2/access_token",
"callbackURL": "http://127.0.0.1:3000/", "callbackURL": "https://127.0.0.1:3000/",
"redirectUrl": "http://127.0.0.1:3000/", "redirectUrl": "https://127.0.0.1:3000/",
"clientID": "real-in-the-private-config", "clientID": "real-in-the-private-config",
"clientSecret": "real-in-the-private-config", "clientSecret": "real-in-the-private-config",
"api":{ "api":{
Expand Down
2 changes: 1 addition & 1 deletion log/.gitignore
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
'*' '*.log'
12 changes: 9 additions & 3 deletions server.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@


var async = require('async'); var async = require('async');
var express = require('express'); var express = require('express');
var http = require('http'); var https = require('https');
var path = require('path'); var path = require('path');
var fs = require('fs');


var site = require('./routes/site'); var site = require('./routes/site');
var user = require('./routes/user'); var user = require('./routes/user');
Expand Down Expand Up @@ -75,8 +76,13 @@ app.post('/api/v1.0/debitoor/register',




function startServer(cb){ function startServer(cb){
http.createServer(app).listen(config.app.port, config.app.host, function(){ var options = {
var serverUrl = 'http://'+config.app.host+':'+config.app.port; key: fs.readFileSync('config/key/key.pem'),
cert: fs.readFileSync('config/key/cert.pem')
};

https.createServer(options, app).listen(config.app.port, config.app.host, function(){
var serverUrl = 'https://'+config.app.host+':'+config.app.port;
log.info('Express server run on: ' + serverUrl); log.info('Express server run on: ' + serverUrl);
cb(null, serverUrl); cb(null, serverUrl);
}); });
Expand Down
3 changes: 3 additions & 0 deletions test/functional.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
//NODE_ENV must be set before exporting app //NODE_ENV must be set before exporting app
process.env.NODE_ENV = 'test'; process.env.NODE_ENV = 'test';


//Accept self signed sertificate. Trivial sertificate for testing
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"

var request = require('supertest'); var request = require('supertest');
var url = require('url'); var url = require('url');
var cheerio = require('cheerio'); var cheerio = require('cheerio');
Expand Down

0 comments on commit e77b0aa

Please sign in to comment.