From d442b7707b35b3daea890b4d35a2a0d564abdd5c Mon Sep 17 00:00:00 2001 From: mo khan Date: Thu, 13 Mar 2025 09:24:51 -0600 Subject: feat: add self-signed tls support --- pkg/cfg/tls.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pkg/cfg/tls.go (limited to 'pkg/cfg') diff --git a/pkg/cfg/tls.go b/pkg/cfg/tls.go new file mode 100644 index 00000000..6414b250 --- /dev/null +++ b/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}, + } + } +} -- cgit v1.2.3