feat: Add show option to the certs plugin
The 'server.key' and 'server.crt' can printed to stdin.
The two options are:
`dokku certs:show <app> key > server.key`
`dokku certs:show <app> crt > server.crt`
This will create two files, `server.key` and `server.crt`.
Those files contain the private key and the certificate.
Includes tests.
This commit is contained in:
@@ -34,6 +34,7 @@ fn-help-content() {
|
||||
certs:remove <app>, Remove an SSL Endpoint from an app
|
||||
certs:report [<app>] [<flag>], Displays an ssl report for one or more apps
|
||||
certs:rollback <app>, [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app
|
||||
certs:show <app> <crt|key>, Show the server.crt or server.key on stdout
|
||||
certs:update <app> CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin
|
||||
help_content
|
||||
}
|
||||
|
||||
28
plugins/certs/subcommands/show
Executable file
28
plugins/certs/subcommands/show
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/certs/functions"
|
||||
|
||||
cmd-certs-show() {
|
||||
declare desc="Show the server.crt or server.key on stdout"
|
||||
declare cmd="certs:show"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1" KEY_TYPE="$2"
|
||||
|
||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
verify_app_name "$APP"
|
||||
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
||||
|
||||
if [[ "$KEY_TYPE" != "key" ]] && [[ "$KEY_TYPE" != "crt" ]]; then
|
||||
dokku_log_fail "specify either 'key' or 'crt'"
|
||||
fi
|
||||
|
||||
if ! is_ssl_enabled "$APP"; then
|
||||
dokku_log_fail "$APP doesn't have an SSL endpoint defined"
|
||||
fi
|
||||
|
||||
cat "$APP_SSL_PATH/server.$KEY_TYPE"
|
||||
}
|
||||
|
||||
cmd-certs-show "$@"
|
||||
Reference in New Issue
Block a user