@@ -24,7 +24,6 @@ import * as helpers from '../core/helpers.mjs'
24
24
import {
25
25
getNodeAccountMap ,
26
26
getNodeLogs ,
27
- getTmpDir ,
28
27
sleep ,
29
28
validatePath
30
29
} from '../core/helpers.mjs'
@@ -317,104 +316,7 @@ export class NodeCommand extends BaseCommand {
317
316
}
318
317
319
318
/**
320
- * Return a list of subtasks to generate gossip keys
321
- *
322
- * WARNING: These tasks MUST run in sequence.
323
- *
324
- * @param keyFormat key format (pem | pfx)
325
- * @param nodeIds node ids
326
- * @param keysDir keys directory
327
- * @param curDate current date
328
- * @param allNodeIds includes the nodeIds to get new keys as well as existing nodeIds that will be included in the public.pfx file
329
- * @return a list of subtasks
330
- * @private
331
- */
332
- // TODO: move to KeyManager
333
- taskGenerateGossipKeys ( keyFormat , nodeIds , keysDir , curDate = new Date ( ) , allNodeIds = null ) {
334
- allNodeIds = allNodeIds || nodeIds
335
- if ( ! Array . isArray ( nodeIds ) || ! nodeIds . every ( ( nodeId ) => typeof nodeId === 'string' ) ) {
336
- throw new IllegalArgumentError ( 'nodeIds must be an array of strings' )
337
- }
338
- const self = this
339
- const subTasks = [ ]
340
-
341
- switch ( keyFormat ) {
342
- case constants . KEY_FORMAT_PFX : {
343
- const tmpDir = getTmpDir ( )
344
- const keytool = self . keytoolDepManager . getKeytool ( )
345
-
346
- subTasks . push ( {
347
- title : `Check keytool exists (Version: ${ self . keytoolDepManager . getKeytoolVersion ( ) } )` ,
348
- task : async ( ) => self . keytoolDepManager . checkVersion ( true )
349
-
350
- } )
351
-
352
- subTasks . push ( {
353
- title : 'Backup old files' ,
354
- task : ( ) => helpers . backupOldPfxKeys ( nodeIds , keysDir , curDate )
355
- } )
356
-
357
- for ( const nodeId of nodeIds ) {
358
- subTasks . push ( {
359
- title : `Generate ${ Templates . renderGossipPfxPrivateKeyFile ( nodeId ) } for node: ${ chalk . yellow ( nodeId ) } ` ,
360
- task : async ( ) => {
361
- await self . keyManager . generatePrivatePfxKeys ( keytool , nodeId , keysDir , tmpDir )
362
- }
363
- } )
364
- }
365
-
366
- subTasks . push ( {
367
- title : `Generate ${ constants . PUBLIC_PFX } file` ,
368
- task : async ( ) => {
369
- await self . keyManager . updatePublicPfxKey ( keytool , allNodeIds , keysDir , tmpDir )
370
- }
371
- } )
372
-
373
- subTasks . push ( {
374
- title : 'Clean up temp files' ,
375
- task : async ( ) => {
376
- if ( fs . existsSync ( tmpDir ) ) {
377
- fs . rmSync ( tmpDir , { recursive : true } )
378
- }
379
- }
380
- } )
381
- break
382
- }
383
-
384
- case constants . KEY_FORMAT_PEM : {
385
- subTasks . push ( {
386
- title : 'Backup old files' ,
387
- task : ( ) => helpers . backupOldPemKeys ( nodeIds , keysDir , curDate )
388
- }
389
- )
390
-
391
- for ( const nodeId of nodeIds ) {
392
- subTasks . push ( {
393
- title : `Gossip ${ keyFormat } key for node: ${ chalk . yellow ( nodeId ) } ` ,
394
- task : async ( ) => {
395
- const signingKey = await this . keyManager . generateSigningKey ( nodeId )
396
- const signingKeyFiles = await this . keyManager . storeSigningKey ( nodeId , signingKey , keysDir )
397
- this . logger . debug ( `generated Gossip signing keys for node ${ nodeId } ` , { keyFiles : signingKeyFiles } )
398
-
399
- const agreementKey = await this . keyManager . generateAgreementKey ( nodeId , signingKey )
400
- const agreementKeyFiles = await this . keyManager . storeAgreementKey ( nodeId , agreementKey , keysDir )
401
- this . logger . debug ( `generated Gossip agreement keys for node ${ nodeId } ` , { keyFiles : agreementKeyFiles } )
402
- }
403
- } )
404
- }
405
-
406
- break
407
- }
408
-
409
- default :
410
- throw new FullstackTestingError ( `unsupported key-format: ${ keyFormat } ` )
411
- }
412
-
413
- return subTasks
414
- }
415
-
416
- /**
417
- * Return a list of subtasks to generate gRPC TLS keys
319
+ * Return a list of subtasks to generate gRPC TLS keys
418
320
*
419
321
* WARNING: These tasks should run in sequence
420
322
*
@@ -744,7 +646,7 @@ export class NodeCommand extends BaseCommand {
744
646
task : async ( ctx , parentTask ) => {
745
647
const config = /** @type {NodeSetupConfigClass } **/ ctx . config
746
648
747
- const subTasks = self . taskGenerateGossipKeys ( config . keyFormat , config . nodeIds , config . keysDir , config . curDate )
649
+ const subTasks = self . keyManager . taskGenerateGossipKeys ( self . keytoolDepManager , config . keyFormat , config . nodeIds , config . keysDir , config . curDate )
748
650
// set up the sub-tasks
749
651
return parentTask . newListr ( subTasks , {
750
652
concurrent : false ,
@@ -1120,7 +1022,7 @@ export class NodeCommand extends BaseCommand {
1120
1022
title : 'Generate gossip keys' ,
1121
1023
task : async ( ctx , parentTask ) => {
1122
1024
const config = ctx . config
1123
- const subTasks = self . taskGenerateGossipKeys ( config . keyFormat , config . nodeIds , config . keysDir , config . curDate )
1025
+ const subTasks = self . keyManager . taskGenerateGossipKeys ( self . keytoolDepManager , config . keyFormat , config . nodeIds , config . keysDir , config . curDate )
1124
1026
// set up the sub-tasks
1125
1027
return parentTask . newListr ( subTasks , {
1126
1028
concurrent : false ,
@@ -1584,7 +1486,7 @@ export class NodeCommand extends BaseCommand {
1584
1486
title : 'Generate Gossip key' ,
1585
1487
task : async ( ctx , parentTask ) => {
1586
1488
const config = /** @type {NodeAddConfigClass } **/ ctx . config
1587
- const subTasks = self . taskGenerateGossipKeys ( config . keyFormat , [ config . nodeId ] , config . keysDir , config . curDate , config . allNodeIds )
1489
+ const subTasks = self . keyManager . taskGenerateGossipKeys ( self . keytoolDepManager , config . keyFormat , [ config . nodeId ] , config . keysDir , config . curDate , config . allNodeIds )
1588
1490
// set up the sub-tasks
1589
1491
return parentTask . newListr ( subTasks , {
1590
1492
concurrent : false ,
0 commit comments