@sassoftware/viya-serverjs 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +2 -2
- package/lib/iService.js +15 -64
- package/package.json +1 -1
- package/src/iService.js +12 -35
package/Dockerfile
CHANGED
|
@@ -31,8 +31,8 @@ ENV HAPIDEBUG=NO
|
|
|
31
31
|
ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:SAS Institute,OU:STO,CN:localhost"
|
|
32
32
|
|
|
33
33
|
# You can specify your own cet and key
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
ENV TLS_CRT=./tls/tls.crt
|
|
35
|
+
ENV TLS_KEY=./tls/tls.key
|
|
36
36
|
|
|
37
37
|
# Samesite specification
|
|
38
38
|
ENV SAMESITE=None,secure
|
package/lib/iService.js
CHANGED
|
@@ -314,81 +314,32 @@ function _getCertificates() {
|
|
|
314
314
|
while (1) switch (_context2.prev = _context2.next) {
|
|
315
315
|
case 0:
|
|
316
316
|
tls = {};
|
|
317
|
-
debug2('Getting tls certificates');
|
|
318
|
-
debug2('tls.crt', process.env['tls.crt'] != null);
|
|
319
|
-
debug2('tls.key', process.env['tls.key'] != null);
|
|
320
|
-
debug2('TLS_PFX', process.env.TLS_PFX != null);
|
|
321
|
-
debug2('TLS_PW', process.env.TLS_PW != null);
|
|
322
|
-
debug2('TLS_CERT', process.env.TLS_CERT != null);
|
|
323
317
|
debug2('TLS_CRT', process.env.TLS_CRT != null);
|
|
324
318
|
debug2('TLS_CREATE', process.env.TLS_CREATE != null);
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
tls.cert = fs.readFileSync(process.env.TLS_CERT);
|
|
332
|
-
tls.key = fs.readFileSync(process.env.TLS_KEY);
|
|
333
|
-
_context2.next = 37;
|
|
334
|
-
break;
|
|
335
|
-
case 15:
|
|
336
|
-
if (!(process.env.TLS_PFX != null)) {
|
|
337
|
-
_context2.next = 21;
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
debug2('TLS set: PFX');
|
|
341
|
-
tls.pfx = fs.readFileSync(process.env.TLS_PFX);
|
|
342
|
-
if (process.env.TLS_PW != null) {
|
|
343
|
-
tls.passphrase = process.env.TLS_PW;
|
|
344
|
-
}
|
|
345
|
-
_context2.next = 37;
|
|
346
|
-
break;
|
|
347
|
-
case 21:
|
|
348
|
-
if (!(process.env.TLS_CRT != null && process.env.TLS_CRT.trim().length > 0)) {
|
|
349
|
-
_context2.next = 27;
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
/* new key names to conform to k8s*/
|
|
353
|
-
debug2('TLS set: TLS_CRT');
|
|
354
|
-
tls.cert = process.env.TLS_CRT;
|
|
355
|
-
tls.key = process.env.TLS_KEY;
|
|
356
|
-
_context2.next = 37;
|
|
357
|
-
break;
|
|
358
|
-
case 27:
|
|
359
|
-
if (!(process.env['tls.crt'] != null)) {
|
|
360
|
-
_context2.next = 32;
|
|
361
|
-
break;
|
|
319
|
+
if (process.env.TLS_CRT != null && process.env.TLS_CRT.length > 0) {
|
|
320
|
+
if (fs.existsSync(process.env.TLS_CRT) && fs.existsSync(process.env.TLS_KEY)) {
|
|
321
|
+
console.log('TLS_CRT and TLS_KEY exist');
|
|
322
|
+
tls.cert = fs.readFileSync(process.env.TLS_CRT);
|
|
323
|
+
tls.key = fs.readFileSync(process.env.TLS_KEY);
|
|
324
|
+
}
|
|
362
325
|
}
|
|
363
|
-
tls.cert
|
|
364
|
-
|
|
365
|
-
_context2.next = 37;
|
|
366
|
-
break;
|
|
367
|
-
case 32:
|
|
368
|
-
if (!(process.env.TLS_CREATE != null)) {
|
|
369
|
-
_context2.next = 37;
|
|
326
|
+
if (!(tls.cert == null && process.env.TLS_CREATE != null)) {
|
|
327
|
+
_context2.next = 10;
|
|
370
328
|
break;
|
|
371
329
|
}
|
|
372
330
|
/* unsigned certificate */
|
|
331
|
+
console.log('Creating selfsigned certificate');
|
|
373
332
|
debug2('TLS set: TLS_CREATE=', process.env.TLS_CREATE);
|
|
374
|
-
_context2.next =
|
|
333
|
+
_context2.next = 9;
|
|
375
334
|
return getTls();
|
|
376
|
-
case
|
|
335
|
+
case 9:
|
|
377
336
|
tls = _context2.sent;
|
|
378
|
-
case
|
|
379
|
-
if (
|
|
380
|
-
|
|
337
|
+
case 10:
|
|
338
|
+
if (Object.keys(tls).length === 0) {
|
|
339
|
+
console.log('Warning: The current host protocol is https: No TLS certificate information has been specified.');
|
|
381
340
|
}
|
|
382
|
-
debug2('TLS', tls);
|
|
383
|
-
if (!(Object.keys(tls).length > 0)) {
|
|
384
|
-
_context2.next = 43;
|
|
385
|
-
break;
|
|
386
|
-
}
|
|
387
|
-
return _context2.abrupt("return", tls);
|
|
388
|
-
case 43:
|
|
389
|
-
console.log('Warning: The current host protocol is https: No TLS certificate information has been specified.');
|
|
390
341
|
return _context2.abrupt("return", tls);
|
|
391
|
-
case
|
|
342
|
+
case 12:
|
|
392
343
|
case "end":
|
|
393
344
|
return _context2.stop();
|
|
394
345
|
}
|
package/package.json
CHANGED
package/src/iService.js
CHANGED
|
@@ -259,49 +259,26 @@ function iService (userRouteTable, useDefault, asset, allAppEnv, serverMode, use
|
|
|
259
259
|
async function getCertificates () {
|
|
260
260
|
|
|
261
261
|
let tls = {};
|
|
262
|
-
debug2('Getting tls certificates');
|
|
263
|
-
debug2('tls.crt', process.env['tls.crt'] != null);
|
|
264
|
-
debug2('tls.key', process.env['tls.key'] != null);
|
|
265
|
-
debug2('TLS_PFX', process.env.TLS_PFX != null);
|
|
266
|
-
debug2('TLS_PW', process.env.TLS_PW != null);
|
|
267
|
-
debug2('TLS_CERT', process.env.TLS_CERT != null);
|
|
268
262
|
debug2('TLS_CRT', process.env.TLS_CRT != null);
|
|
269
263
|
debug2('TLS_CREATE', process.env.TLS_CREATE != null);
|
|
270
|
-
if (process.env.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
} else if (process.env.TLS_PFX != null) {
|
|
276
|
-
debug2('TLS set: PFX');
|
|
277
|
-
tls.pfx = fs.readFileSync(process.env.TLS_PFX);
|
|
278
|
-
if (process.env.TLS_PW != null) {
|
|
279
|
-
tls.passphrase = process.env.TLS_PW;
|
|
264
|
+
if (process.env.TLS_CRT != null && process.env.TLS_CRT.length > 0) {
|
|
265
|
+
if (fs.existsSync(process.env.TLS_CRT) && fs.existsSync(process.env.TLS_KEY)) {
|
|
266
|
+
console.log('TLS_CRT and TLS_KEY exist');
|
|
267
|
+
tls.cert = fs.readFileSync(process.env.TLS_CRT);
|
|
268
|
+
tls.key = fs.readFileSync(process.env.TLS_KEY);
|
|
280
269
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
tls.cert = process.env.TLS_CRT;
|
|
285
|
-
tls.key = process.env.TLS_KEY;
|
|
286
|
-
} else if (process.env['tls.crt'] != null) {
|
|
287
|
-
tls.cert = process.env['tls.crt'];
|
|
288
|
-
tls.key = process.env['tls.key'];
|
|
289
|
-
} else if (process.env.TLS_CREATE != null) {
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
if (tls.cert == null && process.env.TLS_CREATE != null) {
|
|
290
273
|
/* unsigned certificate */
|
|
274
|
+
console.log('Creating selfsigned certificate');
|
|
291
275
|
debug2('TLS set: TLS_CREATE=', process.env.TLS_CREATE);
|
|
292
276
|
tls = await getTls();
|
|
293
277
|
}
|
|
294
|
-
|
|
295
|
-
if (process.env.TLS_CABUNDLE != null) {
|
|
296
|
-
tls.CA = fs.readFileSync(process.env.TLS_CABUNDLE);
|
|
297
|
-
}
|
|
298
|
-
debug2('TLS', tls);
|
|
299
|
-
if (Object.keys(tls).length > 0) {
|
|
300
|
-
return tls;
|
|
301
|
-
} else {
|
|
278
|
+
if (Object.keys(tls).length === 0){
|
|
302
279
|
console.log('Warning: The current host protocol is https: No TLS certificate information has been specified.');
|
|
303
|
-
|
|
304
|
-
|
|
280
|
+
}
|
|
281
|
+
return tls;
|
|
305
282
|
}
|
|
306
283
|
|
|
307
284
|
async function getTls () {
|