-----BEGIN CERTIFICATE----- | |||||
MIIDgjCCAmoCCQCFn/Kp0FpNazANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMC | |||||
REUxDzANBgNVBAgMBkJheWVybjESMBAGA1UEBwwJTnVlcm5iZXJnMQwwCgYDVQQK | |||||
DANvaG0xETAPBgNVBAsMCG1lZGlhZW5nMQ4wDAYDVQQDDAVWZWVwczEdMBsGCSqG | |||||
SIb3DQEJARYOZmFrZWFjY0BnbXguZGUwHhcNMTgxMTI3MjE1NDIyWhcNMTgxMjI3 | |||||
MjE1NDIyWjCBgjELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJheWVybjESMBAGA1UE | |||||
BwwJTnVlcm5iZXJnMQwwCgYDVQQKDANvaG0xETAPBgNVBAsMCG1lZGlhZW5nMQ4w | |||||
DAYDVQQDDAVWZWVwczEdMBsGCSqGSIb3DQEJARYOZmFrZWFjY0BnbXguZGUwggEi | |||||
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDxsNcIe742o+8vTF/zj+qoXhnU | |||||
gDYbaNyc/NP94SzxOArYIwetvsWz6SeIAk5iT/kf9v9CKNJquG2GcKYGnTolIzZB | |||||
h5r+1LA1gCe2q6Gj9RtDHL+s4w9QEEtXovigcy15KP21GdeL/HDEWVDZuFC6Mcn8 | |||||
Zedka3tmQ2VWVhrapCCCHGbCdzSeWQYKIL0EWJOzOCjvlknq2LnzFoTCKIC20qv5 | |||||
MTRaTmzPf2HGFtbpHJm3PdOhd6LtDKGjVCBIwQ+Rks2zUNoUdw83Bk5+XS11bKw6 | |||||
A7wqlwH1molhMwnA8LYat3geSc3ZH964xOjrXFoBSz3dDCoCP3n8P1lh7eHTAgMB | |||||
AAEwDQYJKoZIhvcNAQELBQADggEBAFj6WU9mqSfkvUuALjeVjaCEj+uBCCyB/my8 | |||||
Pahs8m/sjl7h6XbUfPKvqFOb5X93vC6h/dy5cVrkSBDOKOapO6b+s4sGPXvNW79+ | |||||
LIus21ekrBKK3NB8XRFbJrGJnIbvGVHrvDD1HiXIo19PfUTDuFCIt1Uf9FtWP8E7 | |||||
/xusEAQyX8hcGtRiYC3kxj+FtSAq1sIEFtpprD1PHOBCumbMmqj9BaU9i2IXQL6v | |||||
RDxU65XU1dlk3/Y+8BYdtSZ4SiHAjApmp45mNs7myE+mau/OTYTz9NlmdfLkFobd | |||||
lh2hQvSKasHXr4NfpzMoGP4WLO5qzergwzPntcII8CT6nBMKCik= | |||||
-----END CERTIFICATE----- |
-----BEGIN RSA PRIVATE KEY----- | |||||
MIIEpQIBAAKCAQEA8bDXCHu+NqPvL0xf84/qqF4Z1IA2G2jcnPzT/eEs8TgK2CMH | |||||
rb7Fs+kniAJOYk/5H/b/QijSarhthnCmBp06JSM2QYea/tSwNYAntquho/UbQxy/ | |||||
rOMPUBBLV6L4oHMteSj9tRnXi/xwxFlQ2bhQujHJ/GXnZGt7ZkNlVlYa2qQgghxm | |||||
wnc0nlkGCiC9BFiTszgo75ZJ6ti58xaEwiiAttKr+TE0Wk5sz39hxhbW6RyZtz3T | |||||
oXei7Qyho1QgSMEPkZLNs1DaFHcPNwZOfl0tdWysOgO8KpcB9ZqJYTMJwPC2Grd4 | |||||
HknN2R/euMTo61xaAUs93QwqAj95/D9ZYe3h0wIDAQABAoIBAQCeswiviFlhFYnj | |||||
29mRW6mwvoFleH6Oxu89ogItTWMuTSdJvs629nJo7SrI8wK3KV4i8BOyRI3OB6Xb | |||||
RjKuWyUn55QjuUA8HjpKFwl8t/weZb5t9f2iL0IJx3lBZUCuUpLEYPceqIZRZARD | |||||
2YXuQEm5ySGhOuSSmsTfZFexNj7R2vbJBB3ejbY7d5W5B4HxwK/3ZzvzrZk2k1Hs | |||||
//cEA2aTWhNIdY9lOEVRY0fB5HvsM3s3T3y8n9kx8rtcqZml1Edy3WI3jZJHby++ | |||||
oRZkO0ssxeAZLZLQRCwRaa11it7Tpxvm7dU6rsqgc9mU/TFMY7i8uGY54oUBXXrR | |||||
T4LOVj+JAoGBAP1reTCh0T+wA8YN9LhKrMpUwjMDLVNFR0V0u6fo18ORQZcQACKJ | |||||
lsIQZ8PC3q/wjUaoAcd8fOyqmYiVhXRMRahjy2TV0PGuJ/FK4brBaiqsyv8P+ev1 | |||||
tYy98FdPOi3XYhKTLTj/onb2OCOCMc51Hmjvvqm87n1g6ZniaXtyZAiPAoGBAPQm | |||||
y5+GzLonkZUxmpLKOqVM1TsDyTe6GEExsRqoiCAyofR66tx8CVkzXciu5FU/3gCe | |||||
3fuYCLLt6/pnGdKdssMWvWEXIlICxlyqtKp0gtdtdUM1JyK2j7Su2l7n6s4z8WG0 | |||||
UzlaJ5ipgdT9ppWZ40X8nrkgRahfGOXZTK8f4Qx9AoGAP3pMQQJHh8xvJY0ZX5BU | |||||
99mDS4PgNpuD3sH+v3Bzm2knJM+9OOl9+d5iH4cQgMGgobIzv+RO5nlVPAE4DImO | |||||
aT+WEwv76o3VM3uuTzljfo0JzBoUYCaL81Ugfr45tIHe7wguq7hc2a+TIFHcZ/qu | |||||
Q1rKR3orwvwjh4hPI7zjkcECgYEA0FfOyRnp2Czt4aeLpRmnQ+m1x/9qFQDbs75o | |||||
yDvqtbcfVxYRFwdNnu3jaN49gLXYhyUKfqj1O2MmTO7wLTdfFXVxM8nfAqbViLwv | |||||
IYn9IUKJn0lbVRb+uIvBUt2LFF1k7SBJKJbTVUXIwe2V2vGP7OgutgFhD9Xe1D1D | |||||
X+nPTK0CgYEAzSEQsuhLRxvnTlW6GYuBStR/tinsfCMkh9Umz5POzyTRGvtHVR5x | |||||
PZrcaLQXGd4/TV66F/O9CCvu1X5fDhf2RGK9W0EIkkBZfHKw81b5aTyX00dozO8Z | |||||
4r78/uu4o/YTxptH4WxIKEiPm4ODOpNJUMLd6QAz8y3tNqh2fSa9kyA= | |||||
-----END RSA PRIVATE KEY----- |
const fs = require ('fs'), | const fs = require ('fs'), | ||||
http = require ('http'), | http = require ('http'), | ||||
//https = require ('https'), | |||||
https = require ('https'), | |||||
express = require ('express'), | express = require ('express'), | ||||
session = require ('express-session'), // session management | session = require ('express-session'), // session management | ||||
morgan = require ('morgan'), // logger | morgan = require ('morgan'), // logger | ||||
var app = express(); | var app = express(); | ||||
var http_port=8888; | var http_port=8888; | ||||
//https_port=8889; | |||||
https_port=8889; | |||||
/* | /* | ||||
* Init | * Init | ||||
* openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem | * openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem | ||||
* rm certrequest.csr | * rm certrequest.csr | ||||
*/ | */ | ||||
/* | |||||
var options; | var options; | ||||
try { | try { | ||||
try { | try { | ||||
// In case it's a real certificate: add CA chain cersts (TODO: use array if required) | // In case it's a real certificate: add CA chain cersts (TODO: use array if required) | ||||
var ca = fs.readFileSync ('etc/ca_cert.pem'); | |||||
/* Uncomment if real certificate is required and available | |||||
var ca = fs.readFileSync ('keys/ca_cert.pem'); | |||||
} catch (e) { | } catch (e) { | ||||
ca = undefined; | ca = undefined; | ||||
console.log ("Note: Can't read CA bundle: "+e); | console.log ("Note: Can't read CA bundle: "+e); | ||||
} | } | ||||
*/ | |||||
options = { | options = { | ||||
key: fs.readFileSync ('etc/privatekey.pem'), | |||||
cert: fs.readFileSync ('etc/certificate.pem'), | |||||
key: fs.readFileSync ('keys/omkey.pem'), | |||||
cert: fs.readFileSync ('keys/certificate.pem'), | |||||
ca: ca | ca: ca | ||||
}; | }; | ||||
https.createServer (options, app) .listen (https_port, function () { | https.createServer (options, app) .listen (https_port, function () { | ||||
} catch (e) { | } catch (e) { | ||||
console.log ("Note: Can't read SSL keys/certs: "+e+"\nDisabling https server"); | console.log ("Note: Can't read SSL keys/certs: "+e+"\nDisabling https server"); | ||||
} | } | ||||
*/ | |||||
/* | /* | ||||
* Uncaught Exceptions | * Uncaught Exceptions |