From efbbded715ab7e4a54f8fad159185bf17bf7c2d5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 23 Mar 2021 05:07:05 -0400 Subject: [PATCH] fix: properly handle letsencrypt certs in certs:report output Closes dokku/dokku-letsencrypt#199 --- plugins/certs/internal-functions | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/certs/internal-functions b/plugins/certs/internal-functions index ebc86ed2a..fd26e7bcd 100755 --- a/plugins/certs/internal-functions +++ b/plugins/certs/internal-functions @@ -104,7 +104,7 @@ fn-ssl-issuer() { local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" if is_ssl_enabled "$APP"; then - openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Issuer:" | xargs | sed -e "s/Issuer: //g" + openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Issuer:" | head -n1 | sed -e 's/Issuer: //g' -e 's/^[[:space:]]*//' fi } @@ -135,7 +135,12 @@ fn-ssl-verified() { return fi - SSL_VERIFY_OUTPUT="$(openssl verify -verbose -purpose sslserver "$APP_SSL_PATH/server.crt" | awk -F ':' '{ print $2 }' | tail -1 | xargs || true)" + if [[ -f "$APP_SSL_PATH/server.letsencrypt.crt" ]]; then + SSL_VERIFY_OUTPUT="$(openssl verify -verbose -purpose sslserver -CAfile "$APP_SSL_PATH/server.crt" "$APP_SSL_PATH/server.letsencrypt.crt" | awk -F ':' '{ print $2 }' | tail -1 | xargs || true)" + else + SSL_VERIFY_OUTPUT="$(openssl verify -verbose -purpose sslserver "$APP_SSL_PATH/server.crt" | awk -F ':' '{ print $2 }' | tail -1 | xargs || true)" + fi + if [[ "$SSL_VERIFY_OUTPUT" == "OK" ]]; then SSL_SELF_SIGNED="verified by a certificate authority" fi