@@ -34,6 +34,7 @@ func applyConfig(ctx context.Context, p *pb.Config, c *model.Config) error {
3434
3535 opts := []applyOpt {
3636 {"ca" , applyCertificateAuthority },
37+ {"client ca" , applyClientCertificate },
3738 {"certs" , applyCerts },
3839 {"authenticate" , applyAuthenticate },
3940 {"cookie" , applyCookie },
@@ -132,6 +133,26 @@ func applyCertificateAuthority(_ context.Context, p *pb.Config, c *model.Config)
132133 return nil
133134}
134135
136+ func applyClientCertificate (_ context.Context , p * pb.Config , c * model.Config ) error {
137+ if len (c .ClientCASecrets ) == 0 {
138+ return nil
139+ }
140+
141+ var crtBuf bytes.Buffer
142+ var crlBuf bytes.Buffer
143+
144+ for _ , secret := range c .ClientCASecrets {
145+ crtBuf .Write (secret .Data [model .CAKey ])
146+ crtBuf .WriteRune ('\n' )
147+ crlBuf .Write (secret .Data [model .CRLKey ])
148+ crlBuf .WriteRune ('\n' )
149+ }
150+
151+ p .Settings .ClientCa = proto .String (base64 .StdEncoding .EncodeToString (crtBuf .Bytes ()))
152+ p .Settings .ClientCrl = proto .String (base64 .StdEncoding .EncodeToString (crlBuf .Bytes ()))
153+ return nil
154+ }
155+
135156func applyCerts (_ context.Context , p * pb.Config , c * model.Config ) error {
136157 if len (c .Certs ) != len (c .Spec .Certificates ) {
137158 return fmt .Errorf ("expected %d cert secrets, only %d was fetched. this is a bug" , len (c .Spec .Certificates ), len (c .Certs ))
0 commit comments