Rename SSL to TLS

This commit is contained in:
Jack Christensen 2013-10-03 08:07:37 -05:00
parent 6990f3f30d
commit b97b012d42
2 changed files with 9 additions and 9 deletions

View File

@ -26,7 +26,7 @@ type ConnectionParameters struct {
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
SSLConfig *tls.Config // config for TLS connection -- nil disables TLS TLSConfig *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,8 +125,8 @@ 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.SSLConfig != nil { if parameters.TLSConfig != nil {
if err = c.startSSL(); err != nil { if err = c.startTLS(); err != nil {
return return
} }
} }
@ -894,7 +894,7 @@ func (c *Connection) rxNotificationResponse(r *MessageReader) (err error) {
return return
} }
func (c *Connection) startSSL() (err error) { func (c *Connection) startTLS() (err error) {
err = binary.Write(c.conn, binary.BigEndian, []int32{8, 80877103}) err = binary.Write(c.conn, binary.BigEndian, []int32{8, 80877103})
if err != nil { if err != nil {
return return
@ -906,11 +906,11 @@ func (c *Connection) startSSL() (err error) {
} }
if response[0] != 'S' { if response[0] != 'S' {
err = errors.New("Could not use SSL") err = errors.New("Could not use TLS")
return return
} }
c.conn = tls.Client(c.conn, c.parameters.SSLConfig) c.conn = tls.Client(c.conn, c.parameters.TLSConfig)
return nil return nil
} }

View File

@ -77,12 +77,12 @@ func TestConnectWithTcp(t *testing.T) {
} }
} }
func TestConnectWithSSL(t *testing.T) { func TestConnectWithTLS(t *testing.T) {
if sslConnectionParameters == nil { if tlsConnectionParameters == nil {
return return
} }
conn, err := pgx.Connect(*sslConnectionParameters) conn, err := pgx.Connect(*tlsConnectionParameters)
if err != nil { if err != nil {
t.Fatal("Unable to establish connection: " + err.Error()) t.Fatal("Unable to establish connection: " + err.Error())
} }