Skip to content

Commit ed10842

Browse files
committed
Add support for connecting to postgres over TLS
1 parent c099e87 commit ed10842

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

cmd/wal-listener/init.go

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"crypto/tls"
56
"fmt"
67
"log/slog"
78

@@ -24,6 +25,12 @@ func initPgxConnections(cfg *config.DatabaseCfg, logger *slog.Logger) (*pgx.Conn
2425
Password: cfg.Password,
2526
}
2627

28+
if cfg.SSL {
29+
pgxConf.TLSConfig = &tls.Config{
30+
InsecureSkipVerify: true,
31+
}
32+
}
33+
2734
pgConn, err := pgx.Connect(pgxConf)
2835
if err != nil {
2936
return nil, nil, fmt.Errorf("db connection: %w", err)

config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ type DatabaseCfg struct {
6565
Name string `valid:"required"`
6666
User string `valid:"required"`
6767
Password string `valid:"required" mapstructure:"password"`
68+
SSL bool `mapstructure:"ssl"`
6869
}
6970

7071
// IncludeStruct incoming WAL message filter.

0 commit comments

Comments
 (0)