fix(tls): add host.docker.internal to self-signed cert SANs (#1821)

Lambda containers reach Floci via host.docker.internal when Floci
runs on the host instead of in a container, but the cert never
included it as a SAN, failing TLS verification.
This commit is contained in:
Eduardo Lugo Vela authored and GitHub committed 2026-07-10 23:24:03 -05:00
1 parent fe2008848f
commit 9b63b31530
4 files changed
+16 -8

No files matched your search

@@ -229,7 +229,7 @@ class TlsCertificateHostnameTest {
List<String> sans = extractSansFromCertificate(cert);
Set<String> expectedSans = Set.of("localhost", "127.0.0.1", "0.0.0.0", "*.localhost",
"localhost.floci.io", "*.localhost.floci.io");
"localhost.floci.io", "*.localhost.floci.io", "host.docker.internal");
Set<String> actualSans = new HashSet<>(sans);
assertEquals(expectedSans, actualSans,
@@ -252,7 +252,7 @@ class TlsCertificateHostnameTest {
List<String> sans = extractSansFromCertificate(cert);
Set<String> expectedSans = Set.of("localhost", "127.0.0.1", "0.0.0.0", "*.localhost",
"localhost.floci.io", "*.localhost.floci.io");
"localhost.floci.io", "*.localhost.floci.io", "host.docker.internal");
Set<String> actualSans = new HashSet<>(sans);
assertEquals(expectedSans, actualSans,
@@ -158,9 +158,12 @@ class TlsConfigSourceCertificateGenerationTest {
assertTrue(sans.contains("0.0.0.0"),
"Certificate SANs should include default '0.0.0.0'");
assertTrue(sans.contains("host.docker.internal"),
"Certificate SANs should include default 'host.docker.internal'");
// Should not contain any custom hostnames
assertEquals(6, sans.size(),
"Certificate SANs should contain exactly 6 default entries (localhost, 127.0.0.1, 0.0.0.0, *.localhost, localhost.floci.io, *.localhost.floci.io)");
assertEquals(7, sans.size(),
"Certificate SANs should contain exactly 7 default entries (localhost, 127.0.0.1, 0.0.0.0, *.localhost, localhost.floci.io, *.localhost.floci.io, host.docker.internal)");
}
/**
@@ -83,6 +83,8 @@ class TlsConfigSourceMetadataPersistenceTest {
"Metadata should contain 'localhost.floci.io'");
assertTrue(metadata.getHostnames().contains("*.localhost.floci.io"),
"Metadata should contain '*.localhost.floci.io'");
assertTrue(metadata.getHostnames().contains("host.docker.internal"),
"Metadata should contain 'host.docker.internal'");
}
/**