Skip to content

Commit

Permalink
fill spec.tls.caCertificate in route with intermediate ca certificate…
Browse files Browse the repository at this point in the history
…s chain

Signed-off-by: Jean-René ROUET <[email protected]>
  • Loading branch information
rouet committed Nov 4, 2024
1 parent ca5e553 commit 4b4145a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/controller/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,16 @@ func (r *RouteController) populateRoute(ctx context.Context, route *routev1.Rout
// final Sanity checks
var key crypto.Signer

// get private key and signed certificate from Secret
// get private key, signed certificate and ca chain certficates from Secret
k, err := utilpki.DecodePrivateKeyBytes(secret.Data["tls.key"])
if err != nil {
return err
}
key = k

certificate, err := utilpki.DecodeX509CertificateBytes(secret.Data["tls.crt"])
certificates, err := utilpki.DecodeX509CertificateSetBytes(secret.Data["tls.crt"])

certificate := certificates[0]
if err != nil {
return err
}
Expand Down Expand Up @@ -596,6 +598,12 @@ func (r *RouteController) populateRoute(ctx context.Context, route *routev1.Rout
}
route.Spec.TLS.Certificate = string(encodedCert)

encodedCAs, err := utilpki.EncodeX509Chain(certificates[1:])
if err != nil {
return err
}
route.Spec.TLS.CACertificate = string(encodedCAs)

_, err = r.routeClient.RouteV1().Routes(route.Namespace).Update(ctx, route, metav1.UpdateOptions{})
return err
}
Expand Down

0 comments on commit 4b4145a

Please sign in to comment.