Move create TLS parameters to common section

The TLS parameters are now shared by both servers and listeners.
This commit is contained in:
Markus Mäkelä
2017-09-11 10:01:00 +03:00
parent dd178875a3
commit b5202a99f4
2 changed files with 39 additions and 34 deletions

View File

@ -18,7 +18,9 @@ exports.handler = function() {}
exports.builder = function(yargs) {
yargs
// Common options
.group(['protocol', 'authenticator', 'authenticator-options'], 'Common create options:')
.group(['protocol', 'authenticator', 'authenticator-options', 'tls-key',
'tls-cert', 'tls-ca-cert', 'tls-version', 'tls-cert-verify-depth'],
'Common create options:')
.option('protocol', {
describe: 'Protocol module name',
type: 'string'
@ -31,6 +33,26 @@ exports.builder = function(yargs) {
describe: 'Option string for the authenticator',
type: 'string'
})
.option('tls-key', {
describe: 'Path to TLS key',
type: 'string'
})
.option('tls-cert', {
describe: 'Path to TLS certificate',
type: 'string'
})
.option('tls-ca-cert', {
describe: 'Path to TLS CA certificate',
type: 'string'
})
.option('tls-version', {
describe: 'TLS version to use',
type: 'string'
})
.option('tls-cert-verify-depth', {
describe: 'TLS certificate verification depth',
type: 'string'
})
// Create server
.group(['services', 'monitors'], 'Create server options:')
@ -58,7 +80,12 @@ exports.builder = function(yargs) {
'port': argv.port,
'protocol': argv.protocol,
'authenticator': argv.authenticator,
'authenticator_options': argv.auth_options
'authenticator_options': argv.auth_options,
'ssl_key': argv['tls-key'],
'ssl_cert': argv['tls-cert'],
'ssl_ca_cert': argv['tls-ca-cert'],
'ssl_version': argv['tls-version'],
'ssl_cert_verify_depth': argv['tls-cert-verify-depth']
}
}
}
@ -128,33 +155,12 @@ exports.builder = function(yargs) {
})
// Create listener
.group(['interface', 'tls-key', 'tls-cert', 'tls-ca-cert', 'tls-version', 'tls-cert-verify-depth'], 'Create listener options:')
.group(['interface'], 'Create listener options:')
.option('interface', {
describe: 'Interface to listen on',
type: 'string',
default: '::'
})
// Should these have ssl as a prefix even though SSL isn't supported?
.option('tls-key', {
describe: 'Path to TLS key',
type: 'string'
})
.option('tls-cert', {
describe: 'Path to TLS certificate',
type: 'string'
})
.option('tls-ca-cert', {
describe: 'Path to TLS CA certificate',
type: 'string'
})
.option('tls-version', {
describe: 'TLS version to use',
type: 'string'
})
.option('tls-cert-verify-depth', {
describe: 'TLS certificate verification depth',
type: 'string'
})
.command('listener <service> <name> <port>', 'Create a new listener', function(yargs) {
return yargs.epilog('The new listener will be taken into use immediately.');
}, function(argv) {
@ -174,7 +180,7 @@ exports.builder = function(yargs) {
'ssl_cert': argv['tls-cert'],
'ssl_ca_cert': argv['tls-ca-cert'],
'ssl_version': argv['tls-version'],
'ssl_cert_verify_depth': argv['tls-cert-verify-depth'],
'ssl_cert_verify_depth': argv['tls-cert-verify-depth']
}
}
}