diff options
| author | mo khan <mo@mokhan.ca> | 2025-03-13 09:24:51 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-03-13 09:24:51 -0600 |
| commit | d442b7707b35b3daea890b4d35a2a0d564abdd5c (patch) | |
| tree | 43cbbd90b2a497af09efa19eec7445e210647f63 /pkg/cfg | |
| parent | 52ca752eb2f55f858a9b943441bdc0e6353dc128 (diff) | |
feat: add self-signed tls support
Diffstat (limited to 'pkg/cfg')
| -rw-r--r-- | pkg/cfg/tls.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/cfg/tls.go b/pkg/cfg/tls.go new file mode 100644 index 0000000..6414b25 --- /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}, + } + } +} |
