mirror of
https://github.com/aljazceru/cyphernode.git
synced 2026-02-02 11:14:20 +01:00
fixed gatekeeper cert recreation
This commit is contained in:
@@ -193,7 +193,6 @@ module.exports = class extends Generator {
|
||||
|
||||
// save gatekeeper key password to check if it changed
|
||||
this.gatekeeper_clientkeyspassword = this.props.gatekeeper_clientkeyspassword;
|
||||
this.gatekeeper_cns = this.props.gatekeeper_cns;
|
||||
|
||||
let r = await this.prompt([{
|
||||
type: 'confirm',
|
||||
@@ -251,16 +250,15 @@ module.exports = class extends Generator {
|
||||
}
|
||||
}
|
||||
|
||||
const oldCNS = (this.gatekeeper_cns||'').split(',').map(e=>e.trim().toLowerCase()).filter(e=>!!e);
|
||||
const newCNS = (this.props.gatekeeper_cns||'').split(',').map(e=>e.trim().toLowerCase()).filter(e=>!!e);
|
||||
|
||||
if( oldCNS.sort().join('') !== newCNS.sort().join('') ||
|
||||
if( this.props.gatekeeper_recreatecert ||
|
||||
!this.props.gatekeeper_sslcert ||
|
||||
!this.props.gatekeeper_sslkey ) {
|
||||
delete this.props.gatekeeper_recreatecert;
|
||||
const cert = new Cert();
|
||||
console.log(chalk.bold.green( '☕ Generating gatekeeper cert. This may take a while ☕' ));
|
||||
try {
|
||||
const result = await cert.create(newCNS);
|
||||
const cns = (this.props.gatekeeper_cns||'').split(',').map(e=>e.trim().toLowerCase()).filter(e=>!!e);
|
||||
const result = await cert.create(cns);
|
||||
if( result.code === 0 ) {
|
||||
this.props.gatekeeper_sslkey = result.key.toString();
|
||||
this.props.gatekeeper_sslcert = result.cert.toString();
|
||||
|
||||
@@ -11,22 +11,22 @@ const prefix = function() {
|
||||
};
|
||||
|
||||
const hasAuthKeys = function( props ) {
|
||||
return props &&
|
||||
props.gatekeeper_keys &&
|
||||
return props &&
|
||||
props.gatekeeper_keys &&
|
||||
props.gatekeeper_keys.configEntries &&
|
||||
props.gatekeeper_keys.configEntries.length > 0;
|
||||
}
|
||||
|
||||
const hasCert = function( props ) {
|
||||
return props &&
|
||||
props.gatekeeper_sslkey &&
|
||||
return props &&
|
||||
props.gatekeeper_sslkey &&
|
||||
props.gatekeeper_sslcert
|
||||
}
|
||||
|
||||
let password = '';
|
||||
|
||||
module.exports = {
|
||||
name: function() {
|
||||
name: function() {
|
||||
return name;
|
||||
},
|
||||
prompts: function( utils ) {
|
||||
@@ -39,55 +39,62 @@ module.exports = {
|
||||
filter: utils._trimFilter,
|
||||
validate: utils._notEmptyValidator
|
||||
},
|
||||
{
|
||||
when: function( props ) {
|
||||
// hacky hack
|
||||
password = props.gatekeeper_clientkeyspassword;
|
||||
return true;
|
||||
},
|
||||
type: 'password',
|
||||
name: 'gatekeeper_clientkeyspassword_c',
|
||||
default: utils._getDefault( 'gatekeeper_clientkeyspassword_c' ),
|
||||
message: prefix()+'Config your client keys password.'+utils._getHelp('gatekeeper_clientkeyspassword_c'),
|
||||
filter: utils._trimFilter,
|
||||
validate: function( input ) {
|
||||
if(input !== password) {
|
||||
throw new Error( 'Client keys passwords do not match' );
|
||||
{
|
||||
when: function( props ) {
|
||||
// hacky hack
|
||||
password = props.gatekeeper_clientkeyspassword;
|
||||
return true;
|
||||
},
|
||||
type: 'password',
|
||||
name: 'gatekeeper_clientkeyspassword_c',
|
||||
default: utils._getDefault( 'gatekeeper_clientkeyspassword_c' ),
|
||||
message: prefix()+'Confirm your client keys password.'+utils._getHelp('gatekeeper_clientkeyspassword_c'),
|
||||
filter: utils._trimFilter,
|
||||
validate: function( input ) {
|
||||
if(input !== password) {
|
||||
throw new Error( 'Client keys passwords do not match' );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
when: function() { return hasAuthKeys( utils.props ); },
|
||||
type: 'confirm',
|
||||
name: 'gatekeeper_recreatekeys',
|
||||
default: false,
|
||||
message: prefix()+'Recreate gatekeeper keys?'+utils._getHelp('gatekeeper_recreatekeys')
|
||||
},
|
||||
{
|
||||
when: function() { return hasCert( utils.props ); },
|
||||
type: 'input',
|
||||
name: 'gatekeeper_cns',
|
||||
default: utils._getDefault( 'gatekeeper_cns' ),
|
||||
message: prefix()+'Gatekeeper cert CNS (ips, domains, wildcard domains seperated by comma)?'+utils._getHelp('gatekeeper_cns')
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'gatekeeper_edit_apiproperties',
|
||||
default: false,
|
||||
message: prefix()+'Edit API properties?'+utils._getHelp('gatekeeper_edit_apiproperties')
|
||||
},
|
||||
{
|
||||
when: function( props ) {
|
||||
const r = props.gatekeeper_edit_apiproperties;
|
||||
delete props.gatekeeper_edit_apiproperties;
|
||||
return r;
|
||||
},
|
||||
type: 'editor',
|
||||
name: 'gatekeeper_apiproperties',
|
||||
message: utils._getHelp('gatekeeper_apiproperties')||' ',
|
||||
default: utils._getDefault( 'gatekeeper_apiproperties' )
|
||||
}];
|
||||
{
|
||||
when: function() { return hasAuthKeys( utils.props ); },
|
||||
type: 'confirm',
|
||||
name: 'gatekeeper_recreatekeys',
|
||||
default: false,
|
||||
message: prefix()+'Recreate gatekeeper keys?'+utils._getHelp('gatekeeper_recreatekeys')
|
||||
},
|
||||
{
|
||||
when: function() { return hasCert( utils.props ); },
|
||||
type: 'confirm',
|
||||
name: 'gatekeeper_recreatecert',
|
||||
default: false,
|
||||
message: prefix()+'Recreate gatekeeper certificate?'+utils._getHelp('gatekeeper_recreatecert')
|
||||
},
|
||||
{
|
||||
when: function(props) { return !hasCert( utils.props ) || props.gatekeeper_recreatecert },
|
||||
type: 'input',
|
||||
name: 'gatekeeper_cns',
|
||||
default: utils._getDefault( 'gatekeeper_cns' ),
|
||||
message: prefix()+'Gatekeeper cert CNS (ips, domains, wildcard domains seperated by comma)?'+utils._getHelp('gatekeeper_cns')
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'gatekeeper_edit_apiproperties',
|
||||
default: false,
|
||||
message: prefix()+'Edit API properties?'+utils._getHelp('gatekeeper_edit_apiproperties')
|
||||
},
|
||||
{
|
||||
when: function( props ) {
|
||||
const r = props.gatekeeper_edit_apiproperties;
|
||||
delete props.gatekeeper_edit_apiproperties;
|
||||
return r;
|
||||
},
|
||||
type: 'editor',
|
||||
name: 'gatekeeper_apiproperties',
|
||||
message: utils._getHelp('gatekeeper_apiproperties')||' ',
|
||||
default: utils._getDefault( 'gatekeeper_apiproperties' )
|
||||
}];
|
||||
},
|
||||
templates: function( props ) {
|
||||
return [ 'keys.properties', 'api.properties', 'cert.pem', 'key.pem' ];
|
||||
|
||||
Reference in New Issue
Block a user