Skip to content

Commit e5a9184

Browse files
committed
#47 - Set TLSConfig Server name per server we're connecting to
1 parent 4b410bc commit e5a9184

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func (c *Session) connect() error {
5858

5959
// Build auth options
6060
if c.opts.User != "" {
61-
6261
rootCertPemData, err := ioutil.ReadFile(c.opts.CARootCert)
6362
if err != nil {
6463
return errors.New("Opening CARootCert: " + err.Error())
@@ -70,7 +69,6 @@ func (c *Session) connect() error {
7069
}
7170

7271
tlsConf := &tls.Config{
73-
ServerName: "localhost",
7472
InsecureSkipVerify: true,
7573
RootCAs: rootCertPool,
7674
}
@@ -96,6 +94,12 @@ func (c *Session) connect() error {
9694
address = address + ":" + strconv.FormatUint(uint64(port), 10)
9795
}
9896

97+
// Set ServerName based on the address we're connecting to
98+
if authOptions != nil {
99+
addressWithoutPort := address[0:strings.Index(address, ":")]
100+
authOptions.TlsConfig.ServerName = addressWithoutPort
101+
}
102+
99103
node, err := riak.NewNode(&riak.NodeOptions{
100104
RemoteAddress: address,
101105
AuthOptions: authOptions,

0 commit comments

Comments
 (0)