Skip to content

Commit e202b1f

Browse files
committed
fix: trim trailing dots from certificate SANs
Trailing dots are not supposed to be in the cert SANs, but most implementations allow it. Go 1.25.2 introduced strict validation for DNS names in cert SANs, which leads to CoreDNS issue on GCP: as CoreDNS 1.13.1 was build with Go 1.25.2, it rejects a certSAN: ``` tls: failed to parse certificate from server: x509: SAN dNSName is malformed ``` The FQDN on GCP looks like: `<vm>.c.project.internal.` (note trailing dot). Trim trailing dots when building SANs on all levels. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 7f7079f commit e202b1f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/machinery/resources/secrets/cert_sans.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net"
99
"net/netip"
1010
"slices"
11+
"strings"
1112

1213
"github.com/cosi-project/runtime/pkg/resource"
1314
"github.com/cosi-project/runtime/pkg/resource/meta"
@@ -95,9 +96,12 @@ func (spec *CertSANSpec) AppendIPs(ips ...netip.Addr) {
9596
// AppendDNSNames skipping duplicates.
9697
func (spec *CertSANSpec) AppendDNSNames(dnsNames ...string) {
9798
for _, dnsName := range dnsNames {
99+
// remove trailing dot from the DNS name, as it shouldn't be stored in the cert SANs
100+
dnsName = strings.TrimRight(dnsName, ".")
101+
98102
found := slices.Contains(spec.DNSNames, dnsName)
99103

100-
if !found {
104+
if !found && dnsName != "" {
101105
spec.DNSNames = append(spec.DNSNames, dnsName)
102106
}
103107
}

0 commit comments

Comments
 (0)