Handle case where sslcert file is not specified
[sdnc/oam.git] / admportal / shell / www
1 #!/usr/bin/env node
2 var debug = require('debug')('admportal');
3 var app = require('../server/app');
4 var constants = require('constants');
5 var properties = require(process.env.SDNC_CONFIG_DIR + '/admportal.json');
6 var out_file = "/opt/onap/sdnc/admportal/logs/http_admportal.log";
7 var error_file = "/opt/onap/sdnc/admportal/logs/error_http_admportal.log";
8 var cwd = "/opt/onap/sdnc/admportal";
9
10 var fs = require('fs.extra');
11 var https = require('https');
12 var http_port = properties.nonSslPort;
13 var https_port = properties.ConexusNetworkPort;
14 var cert_pswd = process.env.CERT_PSWD;
15 var sslCert = properties.ConexusNetwork_sslCert;
16
17 if (typeof http_port != 'undefined' && http_port.length > 0)
18 {
19         app.set('port', http_port );
20         var server = app.listen(app.get('port'), function() 
21         {
22                 console.log('Express server listening on port ' + server.address().port);
23                 debug('Express server listening on port ' + server.address().port);
24         });
25 }
26
27 if (typeof https_port != 'undefined' && https_port.length > 0 && sslCert.length > 0)
28 {
29         var sslOptions = {
30                 pfx: fs.readFileSync(sslCert),
31                 passphrase: properties.ConexusNetwork_sslKey,
32                 secureOptions: constants.SSL_OP_NO_TLSv1|constants.SSL_OP_NO_SSLv2|constants.SSL_OP_NO_SSLv3,
33                 ciphers: [ "AES128-GCM-SHA256","!RC4","HIGH","!MD5","!aNULL","!EDH","!3DES" ].join(':'),
34                 honorCipherOrder: true,
35                 requestCert: true,
36                 rejectUnauthorized: false
37   };
38   app.set('port', https_port);
39   var secureServer = https.createServer(sslOptions,app).listen(app.get('port'), function(){
40     console.log('Express server (https) listening on port ' + secureServer.address().port);
41     debug('Express server (https) listening on port ' + secureServer.address().port);
42   });
43 }