Files
dokku/plugins/certs/subcommands/show
Jose Diaz-Gonzalez fd162f8895 feat: add verify_app_name calls to all shell subcommands
Without this, folks could potentially run commands against invalid applications.
2020-12-27 15:14:11 -05:00

28 lines
705 B
Bash
Executable File

#!/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"
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 "$@"