@@ -50,6 +50,14 @@ type SignalHandler interface {
50
50
Stop ()
51
51
}
52
52
53
+ // TLSConfig contains TLS parameters for Config.
54
+ type TLSConfig struct {
55
+ TLSCertPath string `yaml:"cert_file"`
56
+ TLSKeyPath string `yaml:"key_file"`
57
+ ClientAuth string `yaml:"client_auth_type"`
58
+ ClientCAs string `yaml:"client_ca_file"`
59
+ }
60
+
53
61
// Config for a Server
54
62
type Config struct {
55
63
MetricsNamespace string `yaml:"-"`
@@ -62,8 +70,8 @@ type Config struct {
62
70
GRPCListenPort int `yaml:"grpc_listen_port"`
63
71
GRPCConnLimit int `yaml:"grpc_listen_conn_limit"`
64
72
65
- HTTPTLSConfig web. TLSStruct `yaml:"http_tls_config"`
66
- GRPCTLSConfig web. TLSStruct `yaml:"grpc_tls_config"`
73
+ HTTPTLSConfig TLSConfig `yaml:"http_tls_config"`
74
+ GRPCTLSConfig TLSConfig `yaml:"grpc_tls_config"`
67
75
68
76
RegisterInstrumentation bool `yaml:"register_instrumentation"`
69
77
ExcludeRequestInLog bool `yaml:"-"`
@@ -239,15 +247,25 @@ func New(cfg Config) (*Server, error) {
239
247
var httpTLSConfig * tls.Config
240
248
if len (cfg .HTTPTLSConfig .TLSCertPath ) > 0 && len (cfg .HTTPTLSConfig .TLSKeyPath ) > 0 {
241
249
// Note: ConfigToTLSConfig from prometheus/exporter-toolkit is awaiting security review.
242
- httpTLSConfig , err = web .ConfigToTLSConfig (& cfg .HTTPTLSConfig )
250
+ httpTLSConfig , err = web .ConfigToTLSConfig (& web.TLSStruct {
251
+ TLSCertPath : cfg .HTTPTLSConfig .TLSCertPath ,
252
+ TLSKeyPath : cfg .HTTPTLSConfig .TLSKeyPath ,
253
+ ClientAuth : cfg .HTTPTLSConfig .ClientAuth ,
254
+ ClientCAs : cfg .HTTPTLSConfig .ClientCAs ,
255
+ })
243
256
if err != nil {
244
257
return nil , fmt .Errorf ("error generating http tls config: %v" , err )
245
258
}
246
259
}
247
260
var grpcTLSConfig * tls.Config
248
261
if len (cfg .GRPCTLSConfig .TLSCertPath ) > 0 && len (cfg .GRPCTLSConfig .TLSKeyPath ) > 0 {
249
262
// Note: ConfigToTLSConfig from prometheus/exporter-toolkit is awaiting security review.
250
- grpcTLSConfig , err = web .ConfigToTLSConfig (& cfg .GRPCTLSConfig )
263
+ grpcTLSConfig , err = web .ConfigToTLSConfig (& web.TLSStruct {
264
+ TLSCertPath : cfg .GRPCTLSConfig .TLSCertPath ,
265
+ TLSKeyPath : cfg .GRPCTLSConfig .TLSKeyPath ,
266
+ ClientAuth : cfg .GRPCTLSConfig .ClientAuth ,
267
+ ClientCAs : cfg .GRPCTLSConfig .ClientCAs ,
268
+ })
251
269
if err != nil {
252
270
return nil , fmt .Errorf ("error generating grpc tls config: %v" , err )
253
271
}
0 commit comments