diff --git a/plugins/certs/subcommands/add b/plugins/certs/subcommands/add index c705d1cde..8ba096a93 100755 --- a/plugins/certs/subcommands/add +++ b/plugins/certs/subcommands/add @@ -44,7 +44,7 @@ certs_set() { trap 'popd &> /dev/null || true; rm -rf $CERTS_SET_TMP_WORK_DIR > /dev/null' RETURN tar xvf - <&0 - local CRT_FILE_SEARCH=$(find . -not -path '*/\.*' -type f -name "*.crt") + local CRT_FILE_SEARCH=$(find . -not -path '*/\.*' -type f | grep ".crt$") local CRT_FILE_COUNT=$(printf "%s" "$CRT_FILE_SEARCH" | grep -c '^') if [[ $CRT_FILE_COUNT -lt 1 ]]; then dokku_log_fail "Tar archive is missing .crt file" @@ -54,7 +54,7 @@ certs_set() { local CRT_FILE=$CRT_FILE_SEARCH fi - local KEY_FILE_SEARCH=$(find . -not -path '*/\.*' -type f -name "*.key") + local KEY_FILE_SEARCH=$(find . -not -path '*/\.*' -type f | grep ".key$") local KEY_FILE_COUNT=$(printf "%s" "$KEY_FILE_SEARCH" | grep -c '^') if [[ $KEY_FILE_COUNT -lt 1 ]]; then dokku_log_fail "Tar archive is missing .key file" diff --git a/tests/unit/10_certs.bats b/tests/unit/10_certs.bats index e7978ab13..9b2003b88 100644 --- a/tests/unit/10_certs.bats +++ b/tests/unit/10_certs.bats @@ -6,6 +6,7 @@ setup_local_tls() { TLS=$BATS_TMPDIR/tls mkdir -p $TLS tar xf $BATS_TEST_DIRNAME/server_ssl.tar -C $TLS + tar xf $BATS_TEST_DIRNAME/domain_ssl.tar -C $TLS sudo chown -R dokku:dokku $TLS } @@ -33,6 +34,13 @@ teardown() { assert_success } +@test "(certs) certs:add with multiple dots in the filename" { + run bash -c "dokku certs:add $TEST_APP $BATS_TMPDIR/tls/domain.com.crt $BATS_TMPDIR/tls/domain.com.key" + echo "output: "$output + echo "status: "$status + assert_success +} + @test "(certs) certs:add < tar" { run bash -c "dokku certs:add $TEST_APP < $BATS_TEST_DIRNAME/server_ssl.tar" echo "output: "$output diff --git a/tests/unit/domain_ssl.tar b/tests/unit/domain_ssl.tar new file mode 100644 index 000000000..b10121314 Binary files /dev/null and b/tests/unit/domain_ssl.tar differ