feat: add fingerprint and serial to certs:report

The report described an installed certificate without carrying anything that identified it, so the only exact way to tell whether an app was serving a given certificate was to pull the full PEM back with `certs:show` and compare bytes. That moves certificate material off the server on every check, and the same command with `key` returns the private key. The new `--ssl-fingerprint` and `--ssl-serial` flags answer the same question in a single report read that discloses nothing sensitive. The sample output in the ssl documentation has also been corrected to match what the command actually prints.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-09-02 03:56:02 -04:00
1 parent 0557705ab3
commit 326607e356
4 files changed
+196 -47

No files matched your search

+81
View File
@@ -53,6 +53,18 @@ teardown() {
assert_success
assert_output_contains "/$TEST_APP/tls"
run /bin/bash -c "dokku certs:report $TEST_APP --ssl-fingerprint"
echo "output: $output"
echo "status: $status"
assert_success
assert_output ""
run /bin/bash -c "dokku certs:report $TEST_APP --ssl-serial"
echo "output: $output"
echo "status: $status"
assert_success
assert_output ""
run /bin/bash -c "dokku certs:report $TEST_APP --ssl-invalid-flag"
echo "output: $output"
echo "status: $status"
@@ -118,6 +130,75 @@ teardown() {
assert_output "node-js-app.dokku.me"
}
@test "(certs:report) reports the certificate fingerprint and serial" {
local EXPECTED_FINGERPRINT EXPECTED_SERIAL
EXPECTED_FINGERPRINT="$(openssl x509 -in "$BATS_TMPDIR/tls/server.crt" -noout -fingerprint -sha256 | cut -d= -f2-)"
EXPECTED_SERIAL="$(openssl x509 -in "$BATS_TMPDIR/tls/server.crt" -noout -serial | cut -d= -f2-)"
run /bin/bash -c "dokku certs:add $TEST_APP $BATS_TMPDIR/tls/server.crt $BATS_TMPDIR/tls/server.key"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku certs:report $TEST_APP --ssl-fingerprint"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$EXPECTED_FINGERPRINT"
run /bin/bash -c "dokku certs:report $TEST_APP --ssl-serial"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$EXPECTED_SERIAL"
run /bin/bash -c "dokku certs:report $TEST_APP --format json | jq -r '.fingerprint'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$EXPECTED_FINGERPRINT"
run /bin/bash -c "dokku certs:report $TEST_APP --format json | jq -r '.serial'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$EXPECTED_SERIAL"
}
@test "(certs:report) fingerprint and serial follow a replaced certificate" {
local EXPECTED_FINGERPRINT EXPECTED_SERIAL
EXPECTED_FINGERPRINT="$(openssl x509 -in "$BATS_TMPDIR/tls/domain.com.crt" -noout -fingerprint -sha256 | cut -d= -f2-)"
EXPECTED_SERIAL="$(openssl x509 -in "$BATS_TMPDIR/tls/domain.com.crt" -noout -serial | cut -d= -f2-)"
run /bin/bash -c "dokku certs:add $TEST_APP $BATS_TMPDIR/tls/server.crt $BATS_TMPDIR/tls/server.key"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku certs:report $TEST_APP --ssl-fingerprint"
echo "output: $output"
echo "status: $status"
assert_success
assert_not_output "$EXPECTED_FINGERPRINT"
run /bin/bash -c "dokku certs:update $TEST_APP $BATS_TMPDIR/tls/domain.com.crt $BATS_TMPDIR/tls/domain.com.key"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku certs:report $TEST_APP --ssl-fingerprint"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$EXPECTED_FINGERPRINT"
run /bin/bash -c "dokku certs:report $TEST_APP --ssl-serial"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$EXPECTED_SERIAL"
}
@test "(certs:report) reports the CN and all SANs as hostnames" {
local SANS_TLS="$BATS_TMPDIR/tls-sans"
mkdir -p "$SANS_TLS"