From 2a9cfd465517687930977a6592fdc5aaee6c6f0c Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Thu, 26 Nov 2026 01:46:37 +0100 Subject: [PATCH 1/7] ci: print what the runner's resolvers hand the key check, to find why it fails there --- .github/workflows/keys.yml | 2 + modules/bank-notifications/build.gradle.kts | 7 ++ .../dkim/KeyCheckDiagnosticsLiveTest.java | 115 ++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java diff --git a/.github/workflows/keys.yml b/.github/workflows/keys.yml index 199f127..a30da80 100644 --- a/.github/workflows/keys.yml +++ b/.github/workflows/keys.yml @@ -23,6 +23,8 @@ jobs: distribution: temurin java-version: 25 - uses: gradle/actions/setup-gradle@v6 + # Temporary: which resolver the runner hands the lookup. + - run: cat /etc/resolv.conf; resolvectl status || true; dig +dnssec +cd TXT 20160512._domainkey.fio.cz || true - run: make check-keys # One open issue at a time, however many days it keeps failing. - if: failure() diff --git a/modules/bank-notifications/build.gradle.kts b/modules/bank-notifications/build.gradle.kts index 2cd4899..c16e971 100644 --- a/modules/bank-notifications/build.gradle.kts +++ b/modules/bank-notifications/build.gradle.kts @@ -93,4 +93,11 @@ val checkKeys = classpath = sourceSets.test.get().runtimeClasspath useJUnitPlatform { includeTags("live") } outputs.upToDateWhen { false } + testLogging { + events("failed", "passed") + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL + showCauses = true + showStackTraces = true + showStandardStreams = true + } } diff --git a/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java b/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java new file mode 100644 index 0000000..8fb00ff --- /dev/null +++ b/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java @@ -0,0 +1,115 @@ +package cz.insuit.bank.notification.dkim; + +import java.io.ByteArrayInputStream; +import java.net.InetSocketAddress; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.xbill.DNS.DClass; +import org.xbill.DNS.ExtendedFlags; +import org.xbill.DNS.ExtendedResolver; +import org.xbill.DNS.Flags; +import org.xbill.DNS.Message; +import org.xbill.DNS.Name; +import org.xbill.DNS.OPTRecord; +import org.xbill.DNS.RRSIGRecord; +import org.xbill.DNS.Rcode; +import org.xbill.DNS.Record; +import org.xbill.DNS.ResolverConfig; +import org.xbill.DNS.Section; +import org.xbill.DNS.SimpleResolver; +import org.xbill.DNS.Type; +import org.xbill.DNS.dnssec.ValidatingResolver; + +/** Temporary: prints what the runner's resolvers hand back, to find why the key check fails there. */ +@Tag("live") +class KeyCheckDiagnosticsLiveTest { + + private static final String[][] QUERIES = { + {".", "DNSKEY"}, + {"cz.", "DS"}, + {"cz.", "DNSKEY"}, + {"fio.cz.", "DS"}, + {"fio.cz.", "DNSKEY"}, + {"airbank.cz.", "DS"}, + {"airbank.cz.", "DNSKEY"}, + {"kbinfo.cz.", "DS"}, + {"kbinfo.cz.", "DNSKEY"}, + {"_domainkey.fio.cz.", "TXT"}, + {"20160512._domainkey.fio.cz.", "TXT"}, + {"ab._domainkey.airbank.cz.", "TXT"}, + {"scph0521._domainkey.kbinfo.cz.", "TXT"}, + }; + + private static final String[] KEYS = { + "20160512._domainkey.fio.cz.", "ab._domainkey.airbank.cz.", "scph0521._domainkey.kbinfo.cz." + }; + + @Test + void printWhatTheResolversSee() throws Exception { + List system = ResolverConfig.getCurrentConfig().servers(); + System.out.println("DIAG system resolvers: " + system); + List servers = new ArrayList<>(system); + servers.add(new InetSocketAddress("1.1.1.1", 53)); + for (InetSocketAddress server : servers) { + for (String[] q : QUERIES) { + System.out.println("DIAG raw " + server + " " + q[0] + " " + q[1] + ": " + raw(server, q[0], q[1])); + } + } + for (String upstreamName : new String[] {"system", "1.1.1.1"}) { + ExtendedResolver upstream = + upstreamName.equals("system") ? new ExtendedResolver() : new ExtendedResolver(new String[] { + upstreamName + }); + upstream.setTimeout(Duration.ofSeconds(5)); + ValidatingResolver validating = new ValidatingResolver(upstream); + validating.setAddReasonToAdditional(true); + validating.loadTrustAnchors(new ByteArrayInputStream( + DnssecKeyLookup.ROOT_TRUST_ANCHORS.getBytes(StandardCharsets.US_ASCII))); + for (String key : KEYS) { + long start = System.nanoTime(); + String out; + try { + Message response = validating.send( + Message.newQuery(Record.newRecord(Name.fromString(key), Type.TXT, DClass.IN))); + out = Rcode.string(response.getRcode()) + " AD=" + + response.getHeader().getFlag(Flags.AD) + "\n" + response; + } catch (Exception e) { + out = "threw " + e; + } + System.out.println("DIAG validating via " + upstreamName + " " + key + " in " + + (System.nanoTime() - start) / 1_000_000 + " ms: " + out); + } + } + } + + private static String raw(InetSocketAddress server, String name, String type) { + long start = System.nanoTime(); + try { + SimpleResolver resolver = new SimpleResolver(server); + resolver.setTimeout(Duration.ofSeconds(5)); + resolver.setEDNS(0, 1232, ExtendedFlags.DO, List.of()); + Message query = Message.newQuery(Record.newRecord(Name.fromString(name), Type.value(type), DClass.IN)); + query.getHeader().setFlag(Flags.CD); + Message response = resolver.send(query); + long rrsigs = response.getSection(Section.ANSWER).stream() + .filter(r -> r instanceof RRSIGRecord) + .count(); + long records = response.getSection(Section.ANSWER).size() - rrsigs; + OPTRecord opt = response.getOPT(); + return Rcode.string(response.getRcode()) + " flags=[" + response.getHeader().printFlags() + "] answer=" + + records + " rrsig=" + rrsigs + " authority=" + + response.getSection(Section.AUTHORITY).size() + " bytes=" + response.numBytes() + " opt=" + + (opt == null + ? "none" + : "payload " + opt.getPayloadSize() + " do=" + ((opt.getFlags() & ExtendedFlags.DO) != 0) + + " " + opt.getOptions()) + + " in " + (System.nanoTime() - start) / 1_000_000 + " ms"; + } catch (Exception e) { + return "threw " + e + " in " + (System.nanoTime() - start) / 1_000_000 + " ms"; + } + } +} From 4af022dc13d588bcc808565b47f91153274d6c64 Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Thu, 26 Nov 2026 01:50:05 +0100 Subject: [PATCH 2/7] ci: run the key check on a cold resolver cache, print the validator's reason and resolved's journal --- .github/workflows/keys.yml | 7 +++++-- .../cz/insuit/bank/notification/dkim/DnssecKeyLookup.java | 5 +++-- .../notification/dkim/KeyCheckDiagnosticsLiveTest.java | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/keys.yml b/.github/workflows/keys.yml index a30da80..2adc9a5 100644 --- a/.github/workflows/keys.yml +++ b/.github/workflows/keys.yml @@ -23,9 +23,12 @@ jobs: distribution: temurin java-version: 25 - uses: gradle/actions/setup-gradle@v6 - # Temporary: which resolver the runner hands the lookup. - - run: cat /etc/resolv.conf; resolvectl status || true; dig +dnssec +cd TXT 20160512._domainkey.fio.cz || true - run: make check-keys + # Temporary: what systemd-resolved did during the check, then what each resolver hands back, warm. + - if: always() + run: sudo journalctl -u systemd-resolved --no-pager | tail -60; resolvectl status | head -12; resolvectl statistics + - if: always() + run: KEYS_DIAG=1 ./gradlew :modules:bank-notifications:checkKeys --tests '*KeyCheckDiagnosticsLiveTest' # One open issue at a time, however many days it keeps failing. - if: failure() env: diff --git a/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java b/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java index b6fb3cc..be1ab4f 100644 --- a/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java +++ b/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java @@ -56,10 +56,11 @@ public List getRecords(CharSequence method, CharSequence selector, CharS if (rcode == Rcode.SERVFAIL) { // ValidatingResolver answers SERVFAIL for a bogus answer as well as for a broken upstream; neither is a // key. - throw new PermFailException("DNSSEC validation of " + name + " failed"); + throw new PermFailException("DNSSEC validation of " + name + " failed; DIAG additional=" + + response.getSection(Section.ADDITIONAL)); } if (!response.getHeader().getFlag(Flags.AD)) { - throw new PermFailException("the answer for " + name + " is not DNSSEC-secure"); + throw new PermFailException("the answer for " + name + " is not DNSSEC-secure; DIAG response=" + response); } if (rcode != Rcode.NOERROR) { throw new PermFailException("no key at " + name + ": " + Rcode.string(rcode)); diff --git a/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java b/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java index 8fb00ff..221fda3 100644 --- a/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java +++ b/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java @@ -8,6 +8,7 @@ import java.util.List; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.xbill.DNS.DClass; import org.xbill.DNS.ExtendedFlags; import org.xbill.DNS.ExtendedResolver; @@ -26,6 +27,7 @@ /** Temporary: prints what the runner's resolvers hand back, to find why the key check fails there. */ @Tag("live") +@EnabledIfEnvironmentVariable(named = "KEYS_DIAG", matches = "1") class KeyCheckDiagnosticsLiveTest { private static final String[][] QUERIES = { From b33a80049ec535a9f4f9a94091898d1d6ad8f2d5 Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Thu, 26 Nov 2026 01:58:04 +0100 Subject: [PATCH 3/7] devops: drop the key check diagnostics, keep gradle printing the failure's message --- .github/workflows/keys.yml | 5 - modules/bank-notifications/build.gradle.kts | 11 +- .../notification/dkim/DnssecKeyLookup.java | 5 +- .../dkim/KeyCheckDiagnosticsLiveTest.java | 117 ------------------ 4 files changed, 6 insertions(+), 132 deletions(-) delete mode 100644 modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java diff --git a/.github/workflows/keys.yml b/.github/workflows/keys.yml index 2adc9a5..199f127 100644 --- a/.github/workflows/keys.yml +++ b/.github/workflows/keys.yml @@ -24,11 +24,6 @@ jobs: java-version: 25 - uses: gradle/actions/setup-gradle@v6 - run: make check-keys - # Temporary: what systemd-resolved did during the check, then what each resolver hands back, warm. - - if: always() - run: sudo journalctl -u systemd-resolved --no-pager | tail -60; resolvectl status | head -12; resolvectl statistics - - if: always() - run: KEYS_DIAG=1 ./gradlew :modules:bank-notifications:checkKeys --tests '*KeyCheckDiagnosticsLiveTest' # One open issue at a time, however many days it keeps failing. - if: failure() env: diff --git a/modules/bank-notifications/build.gradle.kts b/modules/bank-notifications/build.gradle.kts index c16e971..72b02f8 100644 --- a/modules/bank-notifications/build.gradle.kts +++ b/modules/bank-notifications/build.gradle.kts @@ -1,3 +1,5 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + plugins { `java-library` } @@ -93,11 +95,6 @@ val checkKeys = classpath = sourceSets.test.get().runtimeClasspath useJUnitPlatform { includeTags("live") } outputs.upToDateWhen { false } - testLogging { - events("failed", "passed") - exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL - showCauses = true - showStackTraces = true - showStandardStreams = true - } + // The message says why a key was refused; the default format prints only the exception's class. + testLogging { exceptionFormat = TestExceptionFormat.FULL } } diff --git a/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java b/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java index be1ab4f..b6fb3cc 100644 --- a/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java +++ b/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java @@ -56,11 +56,10 @@ public List getRecords(CharSequence method, CharSequence selector, CharS if (rcode == Rcode.SERVFAIL) { // ValidatingResolver answers SERVFAIL for a bogus answer as well as for a broken upstream; neither is a // key. - throw new PermFailException("DNSSEC validation of " + name + " failed; DIAG additional=" - + response.getSection(Section.ADDITIONAL)); + throw new PermFailException("DNSSEC validation of " + name + " failed"); } if (!response.getHeader().getFlag(Flags.AD)) { - throw new PermFailException("the answer for " + name + " is not DNSSEC-secure; DIAG response=" + response); + throw new PermFailException("the answer for " + name + " is not DNSSEC-secure"); } if (rcode != Rcode.NOERROR) { throw new PermFailException("no key at " + name + ": " + Rcode.string(rcode)); diff --git a/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java b/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java deleted file mode 100644 index 221fda3..0000000 --- a/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckDiagnosticsLiveTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package cz.insuit.bank.notification.dkim; - -import java.io.ByteArrayInputStream; -import java.net.InetSocketAddress; -import java.nio.charset.StandardCharsets; -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.xbill.DNS.DClass; -import org.xbill.DNS.ExtendedFlags; -import org.xbill.DNS.ExtendedResolver; -import org.xbill.DNS.Flags; -import org.xbill.DNS.Message; -import org.xbill.DNS.Name; -import org.xbill.DNS.OPTRecord; -import org.xbill.DNS.RRSIGRecord; -import org.xbill.DNS.Rcode; -import org.xbill.DNS.Record; -import org.xbill.DNS.ResolverConfig; -import org.xbill.DNS.Section; -import org.xbill.DNS.SimpleResolver; -import org.xbill.DNS.Type; -import org.xbill.DNS.dnssec.ValidatingResolver; - -/** Temporary: prints what the runner's resolvers hand back, to find why the key check fails there. */ -@Tag("live") -@EnabledIfEnvironmentVariable(named = "KEYS_DIAG", matches = "1") -class KeyCheckDiagnosticsLiveTest { - - private static final String[][] QUERIES = { - {".", "DNSKEY"}, - {"cz.", "DS"}, - {"cz.", "DNSKEY"}, - {"fio.cz.", "DS"}, - {"fio.cz.", "DNSKEY"}, - {"airbank.cz.", "DS"}, - {"airbank.cz.", "DNSKEY"}, - {"kbinfo.cz.", "DS"}, - {"kbinfo.cz.", "DNSKEY"}, - {"_domainkey.fio.cz.", "TXT"}, - {"20160512._domainkey.fio.cz.", "TXT"}, - {"ab._domainkey.airbank.cz.", "TXT"}, - {"scph0521._domainkey.kbinfo.cz.", "TXT"}, - }; - - private static final String[] KEYS = { - "20160512._domainkey.fio.cz.", "ab._domainkey.airbank.cz.", "scph0521._domainkey.kbinfo.cz." - }; - - @Test - void printWhatTheResolversSee() throws Exception { - List system = ResolverConfig.getCurrentConfig().servers(); - System.out.println("DIAG system resolvers: " + system); - List servers = new ArrayList<>(system); - servers.add(new InetSocketAddress("1.1.1.1", 53)); - for (InetSocketAddress server : servers) { - for (String[] q : QUERIES) { - System.out.println("DIAG raw " + server + " " + q[0] + " " + q[1] + ": " + raw(server, q[0], q[1])); - } - } - for (String upstreamName : new String[] {"system", "1.1.1.1"}) { - ExtendedResolver upstream = - upstreamName.equals("system") ? new ExtendedResolver() : new ExtendedResolver(new String[] { - upstreamName - }); - upstream.setTimeout(Duration.ofSeconds(5)); - ValidatingResolver validating = new ValidatingResolver(upstream); - validating.setAddReasonToAdditional(true); - validating.loadTrustAnchors(new ByteArrayInputStream( - DnssecKeyLookup.ROOT_TRUST_ANCHORS.getBytes(StandardCharsets.US_ASCII))); - for (String key : KEYS) { - long start = System.nanoTime(); - String out; - try { - Message response = validating.send( - Message.newQuery(Record.newRecord(Name.fromString(key), Type.TXT, DClass.IN))); - out = Rcode.string(response.getRcode()) + " AD=" - + response.getHeader().getFlag(Flags.AD) + "\n" + response; - } catch (Exception e) { - out = "threw " + e; - } - System.out.println("DIAG validating via " + upstreamName + " " + key + " in " - + (System.nanoTime() - start) / 1_000_000 + " ms: " + out); - } - } - } - - private static String raw(InetSocketAddress server, String name, String type) { - long start = System.nanoTime(); - try { - SimpleResolver resolver = new SimpleResolver(server); - resolver.setTimeout(Duration.ofSeconds(5)); - resolver.setEDNS(0, 1232, ExtendedFlags.DO, List.of()); - Message query = Message.newQuery(Record.newRecord(Name.fromString(name), Type.value(type), DClass.IN)); - query.getHeader().setFlag(Flags.CD); - Message response = resolver.send(query); - long rrsigs = response.getSection(Section.ANSWER).stream() - .filter(r -> r instanceof RRSIGRecord) - .count(); - long records = response.getSection(Section.ANSWER).size() - rrsigs; - OPTRecord opt = response.getOPT(); - return Rcode.string(response.getRcode()) + " flags=[" + response.getHeader().printFlags() + "] answer=" - + records + " rrsig=" + rrsigs + " authority=" - + response.getSection(Section.AUTHORITY).size() + " bytes=" + response.numBytes() + " opt=" - + (opt == null - ? "none" - : "payload " + opt.getPayloadSize() + " do=" + ((opt.getFlags() & ExtendedFlags.DO) != 0) - + " " + opt.getOptions()) - + " in " + (System.nanoTime() - start) / 1_000_000 + " ms"; - } catch (Exception e) { - return "threw " + e + " in " + (System.nanoTime() - start) / 1_000_000 + " ms"; - } - } -} From ab5cd94c12df4b75ae51b1fe8a87b370899c8b0a Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Thu, 26 Nov 2026 01:58:05 +0100 Subject: [PATCH 4/7] be: carry the validator's reason in a refused key's message, so a red key check says why --- .../notification/dkim/DnssecKeyLookup.java | 16 +++++++++++++--- .../notification/dkim/KeyCheckLiveTest.java | 19 ++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java b/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java index b6fb3cc..ad28fee 100644 --- a/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java +++ b/modules/bank-notifications/src/main/java/cz/insuit/bank/notification/dkim/DnssecKeyLookup.java @@ -55,11 +55,11 @@ public List getRecords(CharSequence method, CharSequence selector, CharS int rcode = response.getRcode(); if (rcode == Rcode.SERVFAIL) { // ValidatingResolver answers SERVFAIL for a bogus answer as well as for a broken upstream; neither is a - // key. - throw new PermFailException("DNSSEC validation of " + name + " failed"); + // key. Its reason tells the two apart. + throw new PermFailException("DNSSEC validation of " + name + " failed" + reason(response)); } if (!response.getHeader().getFlag(Flags.AD)) { - throw new PermFailException("the answer for " + name + " is not DNSSEC-secure"); + throw new PermFailException("the answer for " + name + " is not DNSSEC-secure" + reason(response)); } if (rcode != Rcode.NOERROR) { throw new PermFailException("no key at " + name + ": " + Rcode.string(rcode)); @@ -73,6 +73,16 @@ public List getRecords(CharSequence method, CharSequence selector, CharS return records; } + /** ValidatingResolver's own explanation, a TXT record of a private class in the additional section, or nothing. */ + private static String reason(Message response) { + for (Record record : response.getSection(Section.ADDITIONAL)) { + if (record.getDClass() == ValidatingResolver.VALIDATION_REASON_QCLASS && record instanceof TXTRecord txt) { + return ": " + String.join("", txt.getStrings()); + } + } + return ""; + } + /** Sends the queries through the machine's own resolvers and validates every answer here. */ static DnssecKeyLookup usingSystemResolvers() { ExtendedResolver upstream = new ExtendedResolver(); diff --git a/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckLiveTest.java b/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckLiveTest.java index 9919596..b503c4d 100644 --- a/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckLiveTest.java +++ b/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckLiveTest.java @@ -57,22 +57,35 @@ private void assertPublishesOnlyPinnedKeys(String selector, String domain) throw } } + // Each refusal is pinned to its kind and carries the validator's reason. A broken resolver fails every validation, + // so the two unsigned zones then go red here instead of passing for the wrong reason. @Test void refusesABogusAnswer() { // A zone kept deliberately broken for testing validators. - assertThrows(PermFailException.class, () -> dns.getRecords("dns/txt", "x", "dnssec-failed.org")); + PermFailException refused = + assertThrows(PermFailException.class, () -> dns.getRecords("dns/txt", "x", "dnssec-failed.org")); + assertRefusedAs("DNSSEC validation of x._domainkey.dnssec-failed.org failed: ", refused); } @Test void stillRefusesCsobSlovakia() { // ČSOB SK pins no key, so DNSSEC alone would decide; csob.sk is not signed, so its e-mails stay Unverified. - assertThrows(PermFailException.class, () -> dns.getRecords("dns/txt", "x", "csob.sk")); + PermFailException refused = + assertThrows(PermFailException.class, () -> dns.getRecords("dns/txt", "x", "csob.sk")); + assertRefusedAs("the answer for x._domainkey.csob.sk is not DNSSEC-secure: ", refused); } @Test void refusesAnUnsignedZone() { // google.com is not DNSSEC-signed; its DKIM key would come back, unproven. - assertThrows(PermFailException.class, () -> dns.getRecords("dns/txt", "20230601", "google.com")); + PermFailException refused = + assertThrows(PermFailException.class, () -> dns.getRecords("dns/txt", "20230601", "google.com")); + assertRefusedAs("the answer for 20230601._domainkey.google.com is not DNSSEC-secure: ", refused); + } + + private static void assertRefusedAs(String prefix, PermFailException refused) { + String message = Objects.requireNonNull(refused.getMessage()); + assertTrue(message.startsWith(prefix) && message.length() > prefix.length(), message); } private static PublicKey publicKey(String record) throws Exception { From 011152dfeb6a0f962f67d2b08560b72ab89c9359 Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Thu, 26 Nov 2026 02:05:38 +0100 Subject: [PATCH 5/7] =?UTF-8?q?ci:=20name=20komer=C4=8Dn=C3=AD=20banka=20a?= =?UTF-8?q?mong=20the=20banks=20whose=20pinned=20keys=20the=20daily=20chec?= =?UTF-8?q?k=20compares?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/keys.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/keys.yml b/.github/workflows/keys.yml index 199f127..ffc855b 100644 --- a/.github/workflows/keys.yml +++ b/.github/workflows/keys.yml @@ -1,7 +1,7 @@ name: keys -# The banks' DKIM keys are pinned in the code (KEY_FINGERPRINTS in AirBank and FioCz). Once a day this compares them with what DNS -# publishes, validated through DNSSEC from the root, and opens an issue when they differ: a bank that rotated its key, +# The banks' DKIM keys are pinned in the code (KEY_FINGERPRINTS in AirBank, FioCz and KomercniBanka). Once a day this +# compares them with what DNS publishes, validated through DNSSEC from the root, and opens an issue when they differ: a bank that rotated its key, # a forged key, or a root key rollover the built-in trust anchors miss. Until a release pins the new key, readers on the # old one get Unverified, so the issue is the start of a release. on: From 21bf3995c14b9e488ef06c5957e0381f045bfd9c Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Thu, 26 Nov 2026 08:31:41 +0100 Subject: [PATCH 6/7] docs: say the refusal tests rely on the reason record dnsjava's validator adds --- .../cz/insuit/bank/notification/dkim/KeyCheckLiveTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckLiveTest.java b/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckLiveTest.java index b503c4d..df012cc 100644 --- a/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckLiveTest.java +++ b/modules/bank-notifications/src/test/java/cz/insuit/bank/notification/dkim/KeyCheckLiveTest.java @@ -58,7 +58,8 @@ private void assertPublishesOnlyPinnedKeys(String selector, String domain) throw } // Each refusal is pinned to its kind and carries the validator's reason. A broken resolver fails every validation, - // so the two unsigned zones then go red here instead of passing for the wrong reason. + // so the two unsigned zones then go red here instead of passing for the wrong reason. The reason is a record that + // dnsjava's ValidatingResolver adds to its answer, so a dnsjava upgrade that stops adding it turns these red too. @Test void refusesABogusAnswer() { // A zone kept deliberately broken for testing validators. From 4d3c6ba91699bb7d3974baf2ef12d019d887b64d Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Thu, 26 Nov 2026 08:31:41 +0100 Subject: [PATCH 7/7] ci: wrap the key check's header comment like its neighbours --- .github/workflows/keys.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/keys.yml b/.github/workflows/keys.yml index ffc855b..0144370 100644 --- a/.github/workflows/keys.yml +++ b/.github/workflows/keys.yml @@ -1,9 +1,9 @@ name: keys # The banks' DKIM keys are pinned in the code (KEY_FINGERPRINTS in AirBank, FioCz and KomercniBanka). Once a day this -# compares them with what DNS publishes, validated through DNSSEC from the root, and opens an issue when they differ: a bank that rotated its key, -# a forged key, or a root key rollover the built-in trust anchors miss. Until a release pins the new key, readers on the -# old one get Unverified, so the issue is the start of a release. +# compares them with what DNS publishes, validated through DNSSEC from the root, and opens an issue when they differ: +# a bank that rotated its key, a forged key, or a root key rollover the built-in trust anchors miss. Until a release +# pins the new key, readers on the old one get Unverified, so the issue is the start of a release. on: workflow_dispatch: schedule: