package server import ( "context" "crypto/tls" "git.pyer.club/kingecg/gohttpd/utils" "golang.org/x/crypto/acme/autocert" ) var CertManager *autocert.Manager func InitCertManager(certDir string) { CertManager = &autocert.Manager{ Prompt: autocert.AcceptTOS, HostPolicy: hostPolicy, Cache: autocert.DirCache(utils.NormalizePath(certDir)), } } func GetTlsConfig() *tls.Config { if CertManager == nil { InitCertManager(utils.NormalizePath("./certs")) } return CertManager.TLSConfig() } func hostPolicy(ctx context.Context, host string) error { return nil }