The bash :report implementation for the certs plugin is replaced with a compiled golang binary. The certificate inspection getters run openssl and reproduce the existing field extraction, so the ssl report keys are unchanged, while collection now happens in parallel and json is marshalled directly. The now-unused fn-ssl-* display helpers are dropped, and fn-certs-set and fn-certs-remove remain for certs:add and certs:remove.
49 lines
1.4 KiB
Bash
49 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
source "$PLUGIN_AVAILABLE_PATH/certs/functions"
|
|
set -eo pipefail
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
|
|
fn-certs-set() {
|
|
declare desc="installs an SSL cert/key pair onto an app"
|
|
declare APP="$1" CRT_FILE="$2" KEY_FILE="$3"
|
|
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
|
|
|
if [[ -z "$CRT_FILE" ]] || [[ -z "$KEY_FILE" ]]; then
|
|
dokku_log_fail "Both CRT and KEY file paths are required"
|
|
fi
|
|
|
|
if [[ ! -r "$CRT_FILE" ]]; then
|
|
dokku_log_fail "CRT file specified not found, please check file paths"
|
|
fi
|
|
|
|
if [[ ! -r "$KEY_FILE" ]]; then
|
|
dokku_log_fail "KEY file specified not found, please check file paths"
|
|
fi
|
|
|
|
mkdir -p "$APP_SSL_PATH"
|
|
rm -f "$APP_SSL_PATH/server.crt" "$APP_SSL_PATH/server.key"
|
|
cp "$CRT_FILE" "$APP_SSL_PATH/server.crt"
|
|
cp "$KEY_FILE" "$APP_SSL_PATH/server.key"
|
|
chmod 750 "$APP_SSL_PATH"
|
|
chmod 640 "$APP_SSL_PATH/server.crt" "$APP_SSL_PATH/server.key"
|
|
plugn trigger post-certs-update "$APP"
|
|
plugn trigger post-domains-update "$APP"
|
|
}
|
|
|
|
fn-certs-remove() {
|
|
declare desc="removes the SSL cert/key pair from an app"
|
|
declare APP="$1"
|
|
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
|
|
|
if [[ ! -d "$APP_SSL_PATH" ]]; then
|
|
dokku_log_fail "An app-specific SSL endpoint is not defined"
|
|
fi
|
|
|
|
dokku_log_info1 "Removing SSL endpoint from $APP"
|
|
rm -rf "$APP_SSL_PATH"
|
|
plugn trigger post-certs-remove "$APP"
|
|
plugn trigger post-domains-update "$APP"
|
|
}
|
|
|