From bc6e98db8c25754bd51a3cd85422f0ed0a8c271a Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Wed, 6 Dec 2023 08:37:35 +0000 Subject: [PATCH] Reformat the tls config --- servers/https.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/servers/https.go b/servers/https.go index 2f90c6b..a6d42a0 100644 --- a/servers/https.go +++ b/servers/https.go @@ -31,21 +31,23 @@ func NewHttpsServer(conf *conf.Conf) *http.Server { rw.Header().Set("Strict-Transport-Security", "max-age=63072000; includeSubDomains") rateLimiter.ServeHTTP(rw, req) }), - TLSConfig: &tls.Config{GetCertificate: func(info *tls.ClientHelloInfo) (*tls.Certificate, error) { - // error out on invalid domains - if !conf.Domains.IsValid(info.ServerName) { - return nil, fmt.Errorf("invalid hostname used: '%s'", info.ServerName) - } + TLSConfig: &tls.Config{ + GetCertificate: func(info *tls.ClientHelloInfo) (*tls.Certificate, error) { + // error out on invalid domains + if !conf.Domains.IsValid(info.ServerName) { + return nil, fmt.Errorf("invalid hostname used: '%s'", info.ServerName) + } - // find a certificate - cert := conf.Certs.GetCertForDomain(info.ServerName) - if cert == nil { - return nil, fmt.Errorf("failed to find certificate for: '%s'", info.ServerName) - } + // find a certificate + cert := conf.Certs.GetCertForDomain(info.ServerName) + if cert == nil { + return nil, fmt.Errorf("failed to find certificate for: '%s'", info.ServerName) + } - // time to return - return cert, nil - }}, + // time to return + return cert, nil + }, + }, ReadTimeout: 150 * time.Second, ReadHeaderTimeout: 150 * time.Second, WriteTimeout: 150 * time.Second,