Skip to content

Commit 404aa2c

Browse files
authored
fail gracefully when client-ca file is not set or doesn't exist (#2358)
1 parent 11f1d0c commit 404aa2c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/lib/server/server.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func GetListenAndServeFunc(logger *logrus.Logger, tlsCertPath, tlsKeyPath, clien
3232

3333
certStore, err := filemonitor.NewCertStore(*tlsCertPath, *tlsKeyPath)
3434
if err != nil {
35-
return nil, fmt.Errorf("Certificate monitoring for metrics (https) failed: %v", err)
35+
return nil, fmt.Errorf("certificate monitoring for metrics (https) failed: %v", err)
3636
}
3737

3838
csw, err := filemonitor.NewWatch(logger, []string{filepath.Dir(*tlsCertPath), filepath.Dir(*tlsKeyPath)}, certStore.HandleFilesystemUpdate)
@@ -41,6 +41,9 @@ func GetListenAndServeFunc(logger *logrus.Logger, tlsCertPath, tlsKeyPath, clien
4141
}
4242
csw.Run(context.Background())
4343
certPoolStore, err := filemonitor.NewCertPoolStore(*clientCAPath)
44+
if err != nil {
45+
return nil, fmt.Errorf("certificate monitoring for client-ca failed: %v", err)
46+
}
4447
cpsw, err := filemonitor.NewWatch(logger, []string{filepath.Dir(*clientCAPath)}, certPoolStore.HandleCABundleUpdate)
4548
if err != nil {
4649
return nil, fmt.Errorf("error creating cert file watcher: %v", err)

0 commit comments

Comments
 (0)