Skip to content

Commit

Permalink
no server name override anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkolasg committed Jul 1, 2018
1 parent e268ded commit 2db79b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion net/client_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (g *grpcClient) conn(p Peer) (*grpc.ClientConn, error) {
c, err = grpc.Dial(p.Address(), append(g.opts, grpc.WithInsecure())...)
} else {
pool := g.manager.Pool()
creds := credentials.NewClientTLSFromCert(pool, p.Address())
creds := credentials.NewClientTLSFromCert(pool, "")
opts := append(g.opts, grpc.WithTransportCredentials(creds))
c, err = grpc.Dial(p.Address(), opts...)
}
Expand Down
7 changes: 6 additions & 1 deletion net/client_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/tls"
"fmt"
"io/ioutil"
"net"
"net/http"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand Down Expand Up @@ -82,9 +83,13 @@ func (r *restClient) doRequest(remote Peer, req *http.Request) ([]byte, error) {

pool := r.manager.Pool()
if remote.IsTLS() {
h, _, err := net.SplitHostPort(remote.Address())
if err != nil {
return nil, err
}
conf := &tls.Config{
RootCAs: pool,
ServerName: remote.Address(),
ServerName: h,
}
client.Transport = &http.Transport{TLSClientConfig: conf}
}
Expand Down
5 changes: 4 additions & 1 deletion net/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net

import (
"context"
"net"
"os"
"path"
"testing"
Expand Down Expand Up @@ -78,7 +79,9 @@ func TestListenerTLS(t *testing.T) {
certPath := path.Join(tmpDir, "server.crt")
keyPath := path.Join(tmpDir, "server.key")
if httpscerts.Check(certPath, keyPath) != nil {
require.NoError(t, httpscerts.Generate(certPath, keyPath, addr1))
h, _, _ := net.SplitHostPort(addr1)
require.NoError(t, httpscerts.Generate(certPath, keyPath, h))
//require.NoError(t, httpscerts.Generate(certPath, keyPath, addr1))
}

service1 := &testService{42}
Expand Down

0 comments on commit 2db79b5

Please sign in to comment.