Skip to content

Commit

Permalink
fix Info passes lock by value
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Jun 29, 2016
1 parent a6bacfe commit 78e558b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions credentials/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (t TLSInfo) AuthType() string {
// tlsCreds is the credentials required for authenticating a connection using TLS.
type tlsCreds struct {
// TLS configuration
config tls.Config
config *tls.Config
}

func (c tlsCreds) Info() ProtocolInfo {
Expand Down Expand Up @@ -158,7 +158,7 @@ func (c *tlsCreds) ClientHandshake(addr string, rawConn net.Conn, timeout time.D
}
c.config.ServerName = addr[:colonPos]
}
conn := tls.Client(rawConn, &c.config)
conn := tls.Client(rawConn, c.config)
if timeout == 0 {
err = conn.Handshake()
} else {
Expand All @@ -177,7 +177,7 @@ func (c *tlsCreds) ClientHandshake(addr string, rawConn net.Conn, timeout time.D
}

func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) {
conn := tls.Server(rawConn, &c.config)
conn := tls.Server(rawConn, c.config)
if err := conn.Handshake(); err != nil {
rawConn.Close()
return nil, nil, err
Expand All @@ -187,7 +187,7 @@ func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error)

// NewTLS uses c to construct a TransportCredentials based on TLS.
func NewTLS(c *tls.Config) TransportCredentials {
tc := &tlsCreds{*c}
tc := &tlsCreds{c}
tc.config.NextProtos = alpnProtoStr

This comment has been minimized.

Copy link
@tamird

tamird Jul 26, 2016

Contributor

This is modifying the incoming tls.Config, which seems bad.

return tc
}
Expand Down

0 comments on commit 78e558b

Please sign in to comment.