1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

test: Make generate_cert use IDNA for certificate fields

In Go 1.10 the TLS library will start to reject DNS SANs which are not
properly formed; and in particular, if they're not IDNA-encoded. See:
 - https://github.com/golang/go/issues/15196
 - 9e76ce7070

The generate_cert utility will write non-IDNA DNS SANs, which the TLS
library does not like, causing our idna tests to fail.

This patch fixes this incompatibility by making generate_cert IDNA-encode
the host names when adding them to the certificate.
This commit is contained in:
Alberto Bertogli
2017-12-08 14:07:42 +00:00
parent f7a4fa895c
commit fcf2cae120

View File

@@ -25,6 +25,8 @@ import (
"os"
"strings"
"time"
"golang.org/x/net/idna"
)
var (
@@ -128,7 +130,13 @@ func main() {
if ip := net.ParseIP(h); ip != nil {
template.IPAddresses = append(template.IPAddresses, ip)
} else {
template.DNSNames = append(template.DNSNames, h)
// We use IDNA-encoded DNS names, otherwise the TLS library won't
// load the certificates.
ih, err := idna.ToASCII(h)
if err != nil {
log.Fatalf("host %q cannot be IDNA-encoded: %v", h, err)
}
template.DNSNames = append(template.DNSNames, ih)
}
}