mirror of https://github.com/jackc/pgx.git
Use tls.Config for TLS configuration
parent
21c1717d45
commit
6990f3f30d
|
@ -25,8 +25,8 @@ type ConnectionParameters struct {
|
||||||
Database string
|
Database string
|
||||||
User string
|
User string
|
||||||
Password string
|
Password string
|
||||||
MsgBufSize int // Size of work buffer used for transcoding messages. For optimal performance, it should be large enough to store a single row from any result set. Default: 1024
|
MsgBufSize int // Size of work buffer used for transcoding messages. For optimal performance, it should be large enough to store a single row from any result set. Default: 1024
|
||||||
SSL bool // Require SSL connection
|
SSLConfig *tls.Config // config for TLS connection -- nil disables TLS
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connection is a PostgreSQL connection handle. It is not safe for concurrent usage.
|
// Connection is a PostgreSQL connection handle. It is not safe for concurrent usage.
|
||||||
|
@ -125,7 +125,7 @@ func Connect(parameters ConnectionParameters) (c *Connection, err error) {
|
||||||
c.preparedStatements = make(map[string]*preparedStatement)
|
c.preparedStatements = make(map[string]*preparedStatement)
|
||||||
c.alive = true
|
c.alive = true
|
||||||
|
|
||||||
if parameters.SSL {
|
if parameters.SSLConfig != nil {
|
||||||
if err = c.startSSL(); err != nil {
|
if err = c.startSSL(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -910,8 +910,7 @@ func (c *Connection) startSSL() (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &tls.Config{InsecureSkipVerify: true}
|
c.conn = tls.Client(c.conn, c.parameters.SSLConfig)
|
||||||
c.conn = tls.Client(c.conn, config)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue