Files
dokku/plugins/certs/subcommands/show
Roland van Laar be0ba28570 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.
2020-07-04 13:14:02 +02:00

29 lines
787 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"
[[ -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 "$@"