change wildcard cert
alex wennerberg alex@alexwennerberg.com
Mon, 02 Nov 2020 07:52:59 -0800
M
gemini.go
→
gemini.go
@@ -57,15 +57,19 @@ server.WriteTimeout = 2 * time.Minute
hostname := strings.SplitN(c.Host, ":", 2)[0] // is this necc? - server.CreateCertificate = func(hostname string) (tls.Certificate, error) { - log.Println("Generating certificate for", hostname) + server.CreateCertificate = func(h string) (tls.Certificate, error) { + wildcard := strings.SplitN(h, ".", 2) + if len(wildcard) == 2 { + h = "*." + wildcard[1] + } + log.Println("Generating certificate for", h) cert, err := gmi.CreateCertificate(gmi.CertificateOptions{ - DNSNames: []string{hostname}, + DNSNames: []string{h}, Duration: time.Minute * 43200, // one month }) if err == nil { // Write the new certificate to disk - err = writeCertificate(path.Join(c.GeminiCertStore, hostname), cert) + err = writeCertificate(path.Join(c.GeminiCertStore, h), cert) } return cert, err }
M
main.go
→
main.go
@@ -196,7 +196,6 @@ }
mw := io.MultiWriter(os.Stdout, logFile) log.SetOutput(mw) - // Generate self signed cert if does not exist. This is not suitable for production. _, err1 := os.Stat(c.TLSCertFile) _, err2 := os.Stat(c.TLSKeyFile) if os.IsNotExist(err1) || os.IsNotExist(err2) {