flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit ddf67161b1e104f89ed248f079bf8b4fed73bddf
parent 7d59dc82f611361c819542efefe6e3837814b013
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Mon,  2 Nov 2020 07:52:59 -0800

change wildcard cert

Diffstat:
Mgemini.go | 12++++++++----
Mmain.go | 1-
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gemini.go b/gemini.go @@ -57,15 +57,19 @@ func runGeminiServer() { 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 } diff --git a/main.go b/main.go @@ -196,7 +196,6 @@ func main() { 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) {