#!/usr/bin/env bash source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/certs/functions" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x cmd-certs-report() { declare desc="displays an ssl report for one or more apps" local cmd="certs:report" local INSTALLED_APPS=$(dokku_apps) local APP="$2" INFO_FLAG="$3" if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" APP="" fi if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then INFO_FLAG="true" fi if [[ -z "$APP" ]]; then for app in $INSTALLED_APPS; do cmd-certs-report-single "$app" "$INFO_FLAG" | tee || true done else cmd-certs-report-single "$APP" "$INFO_FLAG" fi } cmd-certs-report-single() { declare APP="$1" INFO_FLAG="$2" if [[ "$INFO_FLAG" == "true" ]]; then INFO_FLAG="" fi verify_app_name "$APP" local flag_map=( "--ssl-dir: $DOKKU_ROOT/$APP/tls" "--ssl-enabled: $(fn-ssl-enabled "$APP")" "--ssl-hostnames: $(fn-ssl-hostnames "$APP")" "--ssl-expires-at: $(fn-ssl-expires-at "$APP")" "--ssl-issuer: $(fn-ssl-issuer "$APP")" "--ssl-starts-at: $(fn-ssl-starts-at "$APP")" "--ssl-subject: $(fn-ssl-subject "$APP")" "--ssl-verified: $(fn-ssl-verified "$APP")" ) if [[ -z "$INFO_FLAG" ]]; then dokku_log_info2_quiet "$APP ssl information" for flag in "${flag_map[@]}"; do key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')" dokku_log_verbose "$(printf "%-30s %-25s" "${key^}" "${flag#*: }")" done else local match=false; local value_exists=false for flag in "${flag_map[@]}"; do valid_flags="${valid_flags} $(echo "$flag" | cut -d':' -f1)" if [[ "$flag" == "${INFO_FLAG}:"* ]]; then value=${flag#*: } size="${#value}" if [[ "$size" -ne 0 ]]; then echo "$value" && match=true && value_exists=true else match=true fi fi done [[ "$match" == "true" ]] || dokku_log_fail "Invalid flag passed, valid flags:${valid_flags}" [[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed" fi } certs_help_content_func() { declare desc="return certs plugin help content" cat<, [DEPRECATED] Alternative for certs:report certs:add CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate certs:generate DOMAIN, Generate a key and certificate signing request (and self-signed certificate) certs:info , [DEPRECATED] Alternative for certs:report certs:key CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate certs:remove , Remove an SSL Endpoint from an app certs:report [] [], Displays an ssl report for one or more apps certs:rollback , [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app certs:update CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin help_content } certs_help_cmd() { if [[ $1 = "certs:help" ]] ; then echo -e 'Usage: dokku certs[:COMMAND]' echo '' echo 'Manage Dokku apps SSL (TLS) certs.' echo '' echo 'Additional commands:' certs_help_content_func | sort | column -c2 -t -s, elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then certs_help_content_func else cat<