Skip to content

Commit

Permalink
Address @bboreham's comments
Browse files Browse the repository at this point in the history
Signed-off-by: Annanay <annanayagarwal@gmail.com>
  • Loading branch information
annanay25 committed Apr 21, 2020
1 parent b728180 commit 0bda25d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 2 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ func New(cfg Config) (*Server, error) {
// Setup TLS
var httpTLSConfig *tls.Config
if len(cfg.HTTPTLSConfig.TLSCertPath) > 0 && len(cfg.HTTPTLSConfig.TLSKeyPath) > 0 {
// Note: ConfigToTLSConfig from prometheus/node_exporter is awaiting security review.
httpTLSConfig, err = node_https.ConfigToTLSConfig(&cfg.HTTPTLSConfig)
if err != nil {
return nil, fmt.Errorf("error generating http tls config: %v", err)
}
}
var grpcTLSConfig *tls.Config
if len(cfg.GRPCTLSConfig.TLSCertPath) > 0 && len(cfg.GRPCTLSConfig.TLSKeyPath) > 0 {
// Note: ConfigToTLSConfig from prometheus/node_exporter is awaiting security review.
grpcTLSConfig, err = node_https.ConfigToTLSConfig(&cfg.GRPCTLSConfig)
if err != nil {
return nil, fmt.Errorf("error generating grpc tls config: %v", err)
Expand Down
16 changes: 5 additions & 11 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

google_protobuf "github.com/golang/protobuf/ptypes/empty"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
node_https "github.com/prometheus/node_exporter/https"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/httpgrpc"
Expand Down Expand Up @@ -336,18 +335,13 @@ func TestTLSServer(t *testing.T) {
defer server.Shutdown()

clientCert, err := tls.LoadX509KeyPair("certs/client.crt", "certs/client.key")
if err != nil {
log.Warnf("error loading cert %s or key %s, tls disabled", "certs/client.crt", "certs/client.key")
}
require.NoError(t, err)

var caCertPool *x509.CertPool
caCert, err := ioutil.ReadFile(cfg.HTTPTLSConfig.ClientCAs)
if err != nil {
log.Warnf("error loading ca cert %s, tls disabled", cfg.HTTPTLSConfig.ClientCAs)
} else {
caCertPool = x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
}
require.NoError(t, err)

caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)

tlsConfig := &tls.Config{
InsecureSkipVerify: true,
Expand Down

0 comments on commit 0bda25d

Please sign in to comment.