summaryrefslogtreecommitdiff
path: root/pkg/cfg/tls.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-03-13 09:24:51 -0600
committermo khan <mo@mokhan.ca>2025-03-13 09:24:51 -0600
commitd442b7707b35b3daea890b4d35a2a0d564abdd5c (patch)
tree43cbbd90b2a497af09efa19eec7445e210647f63 /pkg/cfg/tls.go
parent52ca752eb2f55f858a9b943441bdc0e6353dc128 (diff)
feat: add self-signed tls support
Diffstat (limited to 'pkg/cfg/tls.go')
-rw-r--r--pkg/cfg/tls.go18
1 files changed, 18 insertions, 0 deletions
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},
+ }
+ }
+}