Commit d442b77

mo khan <mo@mokhan.ca>
2025-03-13 15:24:51
feat: add self-signed tls support
1 parent 52ca752
Changed files (1)
pkg
pkg/cfg/tls.go
@@ -0,0 +1,18 @@
+package cfg
+
+import (
+	"crypto/tls"
+
+	"github.com/xlgmokha/x/pkg/x"
+)
+
+func WithSelfSigned(cert, key string) cfg.Option {
+	certificate := x.Must(tls.LoadX509KeyPair(cert, key))
+
+	return func(config *cfg.Config) {
+		config.TLS = &tls.Config{
+			MinVersion:   tls.VersionTLS13,
+			Certificates: []tls.Certificate{certificate},
+		}
+	}
+}