openshift-routes icon indicating copy to clipboard operation
openshift-routes copied to clipboard

fill spec.tls.caCertificate in route with intermediate ca certificate…

Open rouet opened this issue 1 year ago • 9 comments
trafficstars

fill spec.tls.caCertificate in route with intermediate ca certificate chain

fix #115

wip please review

cc @bengrunt

rouet avatar Nov 04 '24 14:11 rouet

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign munnerz for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

cert-manager-prow[bot] avatar Nov 04 '24 14:11 cert-manager-prow[bot]

Hi @rouet. Thanks for your PR.

I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

cert-manager-prow[bot] avatar Nov 04 '24 14:11 cert-manager-prow[bot]

possible solution for both of the upper comments

  • create empty array caCertificates
  • loop over elements of certificates array
    • check for each cert PublicKeyMatchesCertificate
      • if match set certificate to that element
      • if not match append element to caCertificates
  • if certificate is null return err
  • fill the fields
    • route.Spec.TLS.Key = string(utilpki.EncodePrivateKey(key, cmapi.PKCS1))
    • route.Spec.TLS.Certificate = string(utilpki.EncodeX509(certificate))
    • if length(caCertificates) >0 then route.Spec.TLS.CACertificate = string(utilpki.EncodeX509Chain(caCertificates))

strima avatar Nov 08 '24 08:11 strima

I agree with your proposal, I will correct the proposed code.

But ideally, an inventory of the utilpki.DecodeX509CertificateBytes function should be made, right?

rouet avatar Nov 08 '24 08:11 rouet

made a quick draft for my proposal : https://github.com/strima/openshift-routes/commit/c042ccd59f0868ee978a6fa9817d4b0e19d35a41 and https://github.com/strima/openshift-routes/commit/f80ba3dc5a64aaeabc3331efdb77003693cc11a3 and https://github.com/strima/openshift-routes/commit/d45c2227274ad6ab2ee367b99ef5990fd7699c68

not really tested - just wanted to translate my pseudocode from previous comment into golang

strima avatar Nov 08 '24 09:11 strima

In the sync_test.go file, I don't see a unit test on the populateRoute function and I'm not seasoned enough to write one.

I will therefore propose the code without an associated test.

rouet avatar Nov 08 '24 11:11 rouet

Hello, maybe @SgtCoDFish or @maelvls could give a look at this PR ? Thanks!

Bengrunt avatar Nov 18 '24 15:11 Bengrunt

/ok-to-test

I'll enable testing here, but I'll reply on #115 about this before digging into reviewing code!

SgtCoDFish avatar Nov 19 '24 10:11 SgtCoDFish

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

cert-manager-prow[bot] avatar Jan 17 '25 08:01 cert-manager-prow[bot]