@@ -85,6 +85,7 @@ func init() {
8585 configFlags .Bool ("self-sign" , false , "specifies to allow a self-signed certificate" )
8686 configFlags .String ("cert" , "" , "path to default tls cert" )
8787 configFlags .String ("cluster-cert" , "" , "path to cluster tls ca cert" )
88+ configFlags .String ("client-ca-cert" , "" , "path to tls ca cert for client certs for mtls" )
8889 configFlags .String ("key" , "" , "path to default private tls key" )
8990 configFlags .String ("grpc-cert" , "" , "path to grpc tls cert for GRPC" )
9091 configFlags .String ("grpc-key" , "" , "path to grpc private tls key for GRPC" )
@@ -261,6 +262,7 @@ type config struct {
261262 dapiCertPath string
262263 dapiKeyPath string
263264 clusterCaCertPath string
265+ clientCaCertPath string
264266 rateLimit int
265267 otlpEndpoint string
266268 disableTraces bool
@@ -300,6 +302,7 @@ func readConfig(logger *zap.Logger) *config {
300302 dapiCertPath : viper .GetString ("dapi-cert" ),
301303 dapiKeyPath : viper .GetString ("dapi-key" ),
302304 clusterCaCertPath : viper .GetString ("cluster-cert" ),
305+ clientCaCertPath : viper .GetString ("client-ca-cert" ),
303306 rateLimit : viper .GetInt ("rate-limit" ),
304307 otlpEndpoint : viper .GetString ("otlp-endpoint" ),
305308 disableTraces : viper .GetBool ("disable-traces" ),
@@ -332,6 +335,7 @@ func readConfig(logger *zap.Logger) *config {
332335 zap .Int ("dapiPort" , config .dapiPort ),
333336 zap .Bool ("selfSign" , config .selfSign ),
334337 zap .String ("certPath" , config .certPath ),
338+ zap .String ("clientCaCertPath" , config .clientCaCertPath ),
335339 zap .String ("keyPath" , config .keyPath ),
336340 zap .String ("grpcCertPath" , config .grpcCertPath ),
337341 zap .String ("grpcKeyPath" , config .grpcKeyPath ),
@@ -524,6 +528,17 @@ func startGateway() {
524528 caCertPool .AppendCertsFromPEM (caCert )
525529 }
526530
531+ var clientCaCertPool * x509.CertPool
532+ if config .clientCaCertPath != "" {
533+ clientCaCertPool = x509 .NewCertPool ()
534+ clientCaCert , err := os .ReadFile (config .clientCaCertPath )
535+ if err != nil {
536+ logger .Error ("failed to load client tls ca certificate" , zap .Error (err ))
537+ }
538+
539+ clientCaCertPool .AppendCertsFromPEM (clientCaCert )
540+ }
541+
527542 if config .cbCredsAwsId != "" {
528543 if config .cbUser != "Administrator" || config .cbPass != "password" {
529544 logger .Error ("cannot use cb-pass or cb-user when fetching creds from cloud provider" )
@@ -601,6 +616,7 @@ func startGateway() {
601616 GrpcCertificate : grpcCertificate ,
602617 DapiCertificate : dapiCertificate ,
603618 ClusterCaCert : caCertPool ,
619+ ClientCaCert : clientCaCertPool ,
604620 NumInstances : 1 ,
605621 StartupCallback : func (m * gateway.StartupInfo ) {
606622 webapi .MarkSystemHealthy ()
0 commit comments