all repos — flounder @ ddf67161b1e104f89ed248f079bf8b4fed73bddf

A small site builder for the Gemini protocol

change wildcard cert
alex wennerberg alex@alexwennerberg.com
Mon, 02 Nov 2020 07:52:59 -0800
commit

ddf67161b1e104f89ed248f079bf8b4fed73bddf

parent

7d59dc82f611361c819542efefe6e3837814b013

2 files changed, 8 insertions(+), 5 deletions(-)

jump to
M gemini.gogemini.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.gomain.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) {