Skip to content

Support certs with GeneralTime#167

Open
omertuc wants to merge 1 commit into
rh-ecosystem-edge:mainfrom
omertuc:generaltime
Open

Support certs with GeneralTime#167
omertuc wants to merge 1 commit into
rh-ecosystem-edge:mainfrom
omertuc:generaltime

Conversation

@omertuc

@omertuc omertuc commented Oct 10, 2024

Copy link
Copy Markdown
Member

Background

Recert until now only supported certs with asn1 UTCTime and not GeneralizedTime.

Problem

When golang creates certs with expiration way out in the future, it uses GeneralizedTime instead of UTCTime.

For example:

    4:d=2  hl=2 l=  13 prim: UTCTIME           :240607174402Z
   19:d=2  hl=2 l=  17 prim: UTCTIME           :340605194402+0200

vs

    4:d=2  hl=2 l=  13 prim: UTCTIME           :240607174406Z
   19:d=2  hl=2 l=  19 prim: GENERALIZEDTIME   :21240514194406+0200

Usually this is not a problem, because a typical OCP cluster doesn't have certs this far in the future, but eventually it will become a problem. Also RHOAI has a component (tektoncd) that has certs with expiry 100 years in the future (despite the misleading name that says "Decade" rather than "Century").

Trying to recert a cluster with tektoncd will therefore lead to the following error:

error: |-
  scanning and recertification

  Caused by:
      0: processing discovered objects
      1: regenerating crypto
      2: re-signing cert with subject CN=tekton-triggers-core-interceptors.openshift-pipelines.svc, O=knative.dev
      3: mutating cert
      4: extending expiration
      5: forcefully expiring
      6: evaluating current expiration
      7: GeneralTime not supported

Solution

This PR adds support for asn1 generalized time in recert. It's simply a matter of casting the type correctly, the x509_certificate crate already supports it.

Testing

This PR is untested, waiting for feedback from the user that reported the issue.

@openshift-ci openshift-ci Bot requested review from mresvanis and tsorya October 10, 2024 09:25
@openshift-ci

openshift-ci Bot commented Oct 10, 2024

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: omertuc

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

The pull request process is described here

Details 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

# Background

Recert until now only supported certs with asn1 `UTCTime` and not
`GeneralizedTime`.

# Problem

When golang creates certs with expiration way out in the future, it uses
`GeneralizedTime` instead of `UTCTime`.

For example:

```
    4:d=2  hl=2 l=  13 prim: UTCTIME           :240607174402Z
   19:d=2  hl=2 l=  17 prim: UTCTIME           :340605194402+0200
```

vs

```
    4:d=2  hl=2 l=  13 prim: UTCTIME           :240607174406Z
   19:d=2  hl=2 l=  19 prim: GENERALIZEDTIME   :21240514194406+0200
```

Usually this is not a problem, because a typical OCP cluster doesn't
have certs this far in the future, but eventually it will become a
problem. Also RHOAI has a component (tektoncd) that has certs with
expiry 100 years in the future [1] (despite the misleading name that
says "Decade" rather than "Century").

Trying to recert a cluster with tektoncd will therefore lead to the
following error:

```
error: |-
  scanning and recertification

  Caused by:
      0: processing discovered objects
      1: regenerating crypto
      2: re-signing cert with subject CN=tekton-triggers-core-interceptors.openshift-pipelines.svc, O=knative.dev
      3: mutating cert
      4: extending expiration
      5: forcefully expiring
      6: evaluating current expiration
      7: GeneralTime not supported
```

# Solution

This PR adds support for asn1 generalized time in recert. It's simply a
matter of casting the type correctly, the x509_certificate crate already
supports it.

# Testing

This PR is untested, waiting for feedback from the user that reported
the issue.

[1] https://github.com/tektoncd/triggers/blob/59da11dd50424c9ccef883b558671e34efc0eba5/pkg/interceptors/server/server.go#L36
omertuc added a commit to omertuc/triggers that referenced this pull request Oct 10, 2024
We had an issue [1] with long expiration so I noticed the name was wrong

[1] rh-ecosystem-edge/recert#167
omertuc added a commit to omertuc/triggers that referenced this pull request Oct 10, 2024
We had an issue [1] with long expiration so I noticed the name was wrong

[1] rh-ecosystem-edge/recert#167
omertuc added a commit to omertuc/triggers that referenced this pull request Oct 10, 2024
We had an issue [1] with long expiration so I noticed the name was wrong

[1] rh-ecosystem-edge/recert#167

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
tekton-robot pushed a commit to tektoncd/triggers that referenced this pull request Nov 4, 2024
We had an issue [1] with long expiration so I noticed the name was wrong

[1] rh-ecosystem-edge/recert#167

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
@omertuc

omertuc commented Mar 11, 2025

Copy link
Copy Markdown
Member Author

/retest

@omertuc

omertuc commented Mar 11, 2025

Copy link
Copy Markdown
Member Author

@javipolo did you get a chance to test this?

@javipolo

Copy link
Copy Markdown
Collaborator

@javipolo did you get a chance to test this?

Nope, I didn't find the moment ....

I'll see if I can make some time to do it and verify that it works

@omertuc

omertuc commented Mar 11, 2025

Copy link
Copy Markdown
Member Author

@javipolo did you get a chance to test this?

Nope, I didn't find the moment ....

I'll see if I can make some time to do it and verify that it works

No stress, just popped up in my notifications because the bot was rerunning the job

@openshift-ci

openshift-ci Bot commented May 26, 2026

Copy link
Copy Markdown

@omertuc: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/baremetalds-sno-recert-cluster-rename ae142a1 link true /test baremetalds-sno-recert-cluster-rename
ci/prow/e2e-aws-ovn-single-node-recert-parallel ae142a1 link true /test e2e-aws-ovn-single-node-recert-parallel

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants