Skip to content

Commit 7cb1900

Browse files
committed
Add WithUnsecureTLS option to pg client
Enables TLS connections without verifying the server certificate chain or hostname, complementing the existing verifying WithTLS. Intended for development against self-signed databases.
1 parent e1e5390 commit 7cb1900

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

pg/client.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ func WithTLS(certs []*x509.Certificate) Option {
139139
}
140140
}
141141

142+
// WithUnsecureTLS enables TLS without verifying the server's
143+
// certificate chain or hostname. Intended for development against
144+
// self-signed databases; do not use in production.
145+
func WithUnsecureTLS() Option {
146+
return func(c *Client) {
147+
c.tlsConfig = &tls.Config{
148+
InsecureSkipVerify: true,
149+
MinVersion: tls.VersionTLS12,
150+
}
151+
}
152+
}
153+
142154
// WithPoolSize sets the maximum number of connections the pool will
143155
// open. It maps to pgxpool.Config.MaxConns.
144156
func WithPoolSize(i int32) Option {

0 commit comments

Comments
 (0)