Skip to content

Commit

Permalink
Disable SSL when connecting over a UNIX domain socket
Browse files Browse the repository at this point in the history
Previously if sslmode was not explicitly disabled, trying to connect
over a UNIX domain socket would result in a "pq: SSL is not enabled on
the server" error.  This is both silly and incompatible with libpq.  Fix
by setting "sslmode" to "disable" automatically whenever a connection is
made over a UNIX socket.
  • Loading branch information
johto committed Apr 2, 2015
1 parent ecb6ff4 commit a33d605
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ func DialOpen(d Dialer, name string) (_ driver.Conn, err error) {

func dial(d Dialer, o values) (net.Conn, error) {
ntw, addr := network(o)
// SSL is not necessary or supported over UNIX domain sockets
if ntw == "unix" {
o["sslmode"] = "disable"
}

// Zero or not specified means wait indefinitely.
if timeout := o.Get("connect_timeout"); timeout != "" && timeout != "0" {
Expand Down

0 comments on commit a33d605

Please sign in to comment.