Merge pull request #7654 from thunderbird/fix_mx_lookup_dnssec

Use `DnssecResolverApi` in `MiniDnsMxResolver` to actually use DNSSEC
This commit is contained in:
cketti 2024-02-20 13:18:53 +01:00 committed by GitHub
commit 568c1117dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View file

@ -2,12 +2,12 @@ package app.k9mail.autodiscovery.autoconfig
import app.k9mail.core.common.net.Domain
import app.k9mail.core.common.net.toDomainOrNull
import org.minidns.hla.ResolverApi
import org.minidns.hla.DnssecResolverApi
import org.minidns.record.MX
internal class MiniDnsMxResolver : MxResolver {
override fun lookup(domain: Domain): MxLookupResult {
val result = ResolverApi.INSTANCE.resolve(domain.value, MX::class.java)
val result = DnssecResolverApi.INSTANCE.resolve(domain.value, MX::class.java)
val mxNames = result.answersOrEmptySet
.sortedBy { it.priority }

View file

@ -9,6 +9,7 @@ import assertk.assertions.index
import assertk.assertions.isEmpty
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isTrue
import kotlin.test.Ignore
import kotlin.test.Test
@ -34,6 +35,16 @@ class MiniDnsMxResolverTest {
}
}
@Test
@Ignore("Requires internet")
fun `MX lookup for known domain using DNSSEC`() {
val domain = "posteo.de".toDomain()
val result = resolver.lookup(domain)
assertThat(result.isTrusted).isTrue()
}
@Test
@Ignore("Requires internet")
fun `MX lookup for non-existent domain`() {