Skip to content

Create a resuable verify package for image release verification - #837

Merged
openshift-merge-robot merged 2 commits into
openshift:masterfrom
jottofar:ota-cvo-and-oc-reuse
Aug 25, 2020
Merged

openshift-merge-robot merged 2 commits into
openshift:masterfrom
jottofar:ota-cvo-and-oc-reuse

Conversation

@jottofar

Copy link
Copy Markdown
Contributor

Both the oc client application and the CVO do image release verification. Image release verification was recently added to the oc client and at that time any code required was simply copied from the CVO were it was originally developed. This change moves the code required for image release verification, the CVO package verify, from the CVO into library-go for reuse by CVO and the oc client application and applies any required changes to make it reusable by both.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 16, 2020
@jottofar
jottofar force-pushed the ota-cvo-and-oc-reuse branch 2 times, most recently from 5ed2982 to 7ec1baf Compare July 16, 2020 16:43
@jottofar

Copy link
Copy Markdown
Contributor Author

/retest

@jottofar

Copy link
Copy Markdown
Contributor Author

/retitle Create a resuable verify package for image release verification

@openshift-ci-robot openshift-ci-robot changed the title WIP: Create a resuable verify package for image release verification Create a resuable verify package for image release verification Jul 16, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 16, 2020
@jottofar
jottofar force-pushed the ota-cvo-and-oc-reuse branch from 7ec1baf to f2a7915 Compare July 21, 2020 21:12
@jottofar

Copy link
Copy Markdown
Contributor Author

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 18, 2020
@jottofar
jottofar force-pushed the ota-cvo-and-oc-reuse branch 4 times, most recently from a8f7bc1 to 8ff8d9f Compare August 19, 2020 15:01
@jottofar

Copy link
Copy Markdown
Contributor Author

Created new test cases in pkg/verify/verify_test.go to address openshift/cluster-version-operator#413 (comment).

@jottofar

Copy link
Copy Markdown
Contributor Author

/unhold

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 19, 2020
@jottofar
jottofar force-pushed the ota-cvo-and-oc-reuse branch from 8ff8d9f to d444be4 Compare August 20, 2020 13:26
@jottofar
jottofar force-pushed the ota-cvo-and-oc-reuse branch from d444be4 to 8a3b061 Compare August 21, 2020 15:52
Comment thread pkg/verify/configmap_test.go Resolved
Comment thread pkg/verify/configmap_test.go Resolved
Comment thread pkg/verify/configmap_test.go Resolved
@jottofar
jottofar force-pushed the ota-cvo-and-oc-reuse branch from 8a3b061 to 892e7fb Compare August 24, 2020 17:58
Both the oc client application and the CVO do image release
verification. Image release verification was recently added to the oc
client and at that time any code required was simply copied from the CVO
were it was originally developed. This change moves the code required
for image release verification, the CVO package verify, from the CVO
into library-go for reuse by CVO and the oc client application and
applies any required changes to make it reusabe by both.
@jottofar
jottofar force-pushed the ota-cvo-and-oc-reuse branch from 892e7fb to c43c2cb Compare August 24, 2020 18:12

@wking wking left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ git --no-pager -C cluster-version-operator log -1 --oneline
34010292 (HEAD -> master, wking/master, origin/release-4.7, origin/release-4.6, origin/master, origin/HEAD) Merge pull request #439 from wking/fix-component-regexp-docs
$ git --no-pager -C library-go log -1 --oneline
c43c2cb20 (HEAD, origin/pr/837) Create a resuable verify package for image release verification
$ diff -ru cluster-version-operator/pkg/verify library-go/pkg/verify
...nothing serious...

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 24, 2020
@wking

wking commented Aug 24, 2020

Copy link
Copy Markdown
Member

/close

In case this will help Prow notice #868.

@openshift-ci-robot

Copy link
Copy Markdown

@wking: Closed this PR.

Details

In response to this:

/close

In case this will help Prow notice #868.

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/test-infra repository.

@wking

wking commented Aug 24, 2020

Copy link
Copy Markdown
Member

/reopen

@openshift-ci-robot

Copy link
Copy Markdown

@wking: Reopened this PR.

Details

In response to this:

/reopen

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/test-infra repository.

@wking

wking commented Aug 24, 2020

Copy link
Copy Markdown
Member

/approve

@wking

wking commented Aug 24, 2020

Copy link
Copy Markdown
Member

We need a root-level approver to sign off on this because of the vendor bump in 29a26d3.

/assign @deads2k

@deads2k

deads2k commented Aug 25, 2020

Copy link
Copy Markdown
Contributor

golang/x dep is ok

/approve

@openshift-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, jottofar, wking

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 25, 2020
@openshift-merge-robot
openshift-merge-robot merged commit 3926cf3 into openshift:master Aug 25, 2020
wking added a commit to wking/openshift-library-go that referenced this pull request May 19, 2022
This function calls the callback for each signature, it doesn't return
a list.  Fixes a godoc from the original implementation in c43c2cb
(Create a resuable verify package for image release verification,
2020-07-16, openshift#837).
wking added a commit to wking/openshift-library-go that referenced this pull request Nov 16, 2023
Typo slipped in when the file was created in c43c2cb (Create a
resuable verify package for image release verification, 2020-07-16, openshift#837).
wking added a commit to wking/openshift-library-go that referenced this pull request Nov 24, 2026
The 2007 RFC 4880 encouraged consumer support [1]:

  Implementations SHOULD accept V3 signatures. Implementations SHOULD
  generate V4 signatures.

The 2024 RFC 9580 tightens down against creating new v3 signatures,
and leaves it more open-ended about whether consuming v3 signatures is
a good idea [2]:

  Implementations MUST NOT create version 3 signatures; they MAY
  accept version 3 signatures.

Within OpenShift, the transition from v3 signatures to v4 signatures
happened somewhere during 2023:

  $ for Y in $(seq 3 22); do oc image info -o json "quay.io/openshift-release-dev/ocp-release:4.${Y}.0-x86_64" | jq -r '.config.created + " " + .digest' | while read CREATED DIGEST; do echo -n "4.${Y}.0 ${CREATED} ${DIGEST} "; curl -s "https://mirror.openshift.com/pub/openshift-v4/signatures/openshift/release/${DIGEST/:/=}/signature-1" | gpg --list-packets | grep -A1 'signature packet'; done; done
  4.3.0 2020-01-22T02:05:15Z sha256:3a516480dfd68e0f87f702b4d7bdd6f6a0acfdac5cd2e9767b838ceede34d70d :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 3, created 1579666968, md5len 5, sigclass 0x00
  4.4.0 2020-04-29T13:48:30Z sha256:96cb606d04e94de1954a50ddb965eb02b76e182478bef9225df0ad523cfa6b38 :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 3, created 1588175151, md5len 5, sigclass 0x00
  ...
  4.13.0 2023-05-16T10:09:04Z sha256:74b23ed4bbb593195a721373ed6693687a9b444c97065ce8ac653ba464375711 :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 3, created 1684251879, md5len 5, sigclass 0x00
  4.14.0 2023-10-26T14:31:15Z sha256:e2c70fca183e380c6121a1c847806f11e839482123277235a8579db472b9ccf2 :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 4, created 1698363623, md5len 0, sigclass 0x00
  ...
  4.22.0 2026-06-04T22:31:25Z sha256:283887f2860a745387608d106e70e5be2314df2497ee08c69e7bc669ca091340 :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 4, created 1780635619, md5len 0, sigclass 0x00

So we can safely drop the v3 support here, without breaking anything
trying to parse remotely-modern release signatures.

I'm also dropping the v3 registry.access.redhat.com/rhel7:7.6
signature we'd been using since the initial package commit c43c2cb
(Create a resuable verify package for image release verification,
2020-07-16, openshift#837), descended in turn from
openshift/cluster-version-operator@55e3cb450f (verifier: Add public
key verification of release image digests, 2019-04-20,
openshift/cluster-version-operator#170):

  $ gpg --list-packets < 'pkg/verify/testdata/signatures/sha256=e3f12513a4b22a2d7c0e7c9207f52128113758d9d68c7d06b11a0ac7672966f7/signature-1'
  # off=0 ctb=a3 tag=8 hlen=1 plen=0 indeterminate
  :compressed packet: algo=1
  # off=2 ctb=90 tag=4 hlen=2 plen=13
  :onepass_sig packet: keyid 199E2F91FD431D51
  	version 3, sigclass 0x00, digest 8, pubkey 1, last=1
  # off=17 ctb=ad tag=11 hlen=3 plen=324
  :literal data packet:
  	mode b (62), created 1554833664, name="_rpmsig-req-KOr4fw.bin",
  	raw data: 296 bytes
  # off=344 ctb=89 tag=2 hlen=3 plen=533
  :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 3, created 1554833664, md5len 5, sigclass 0x00
  	digest algo 8, begin of digest 34 f2
  	data: [4095 bits]
  $ gpg --decrypt <pkg/verify/testdata/signatures/sha256\=e3f12513a4b22a2d7c0e7c9207f52128113758d9d68c7d06b11a0ac7672966f7/signature-1  | jq .
  gpg: Signature made Tue 09 Apr 2019 11:14:24 AM PDT
  gpg:                using RSA key 199E2F91FD431D51
  gpg: Good signature from "Red Hat, Inc. (release key 2) <[email protected]>" [unknown]
  gpg: WARNING: This key is not certified with a trusted signature!
  gpg:          There is no indication that the signature belongs to the owner.
  Primary key fingerprint: 567E 347A D004 4ADE 55BA  8A5F 199E 2F91 FD43 1D51
  {
    "critical": {
      "image": {
        "docker-manifest-digest": "sha256:e3f12513a4b22a2d7c0e7c9207f52128113758d9d68c7d06b11a0ac7672966f7"
      },
      "type": "atomic container signature",
      "identity": {
        "docker-reference": "registry.access.redhat.com/rhel7:7.6"
      }
    },
    "optional": {
      "creator": "Red Hat RCM Pub 0.35.0-final "
    }
  }

Instead, I'm using the OpenPGP v4 signature formatted 4.14.0
signature:

  $ curl -s 'https://mirror.openshift.com/pub/openshift-v4/signatures/openshift/release/sha256=e2c70fca183e380c6121a1c847806f11e839482123277235a8579db472b9ccf2/signature-1' > 'pkg/verify/testdata/signatures/sha256=e2c70fca183e380c6121a1c847806f11e839482123277235a8579db472b9ccf2/signature-1'

I'm also dropping (this time without replacement) the old
release-controller signature we'd also been dragging around since
Clayton's 2019 commit:

  $ gpg --list-packets pkg/verify/testdata/signatures/sha256=edd9824f0404f1a139688017e7001370e2f3fbc088b94da84506653b473fe140/signature-1
  # off=0 ctb=c4 tag=4 hlen=2 plen=13 new-ctb
  :onepass_sig packet: keyid 28B76E05B923888E
  	version 3, sigclass 0x00, digest 8, pubkey 1, last=1
  # off=15 ctb=cb tag=11 hlen=2 plen=0 partial new-ctb
  :literal data packet:
  	mode t (74), created 0, name="",
  	raw data: unknown length
  $ gpg --decrypt pkg/verify/testdata/signatures/sha256=edd9824f0404f1a139688017e7001370e2f3fbc088b94da84506653b473fe140/signature-1
  {
    "critical": {
      "type": "atomic container signature",
      "image": {
        "docker-manifest-digest": "sha256:edd9824f0404f1a139688017e7001370e2f3fbc088b94da84506653b473fe140"
      },
      "identity": {
        "docker-reference": "registry.svc.ci.openshift.org/ocp/release:4.0.0-0.ci-2019-04-19-181452"
      }
    },
    "optional": {
      "creator": "openshift release-controller",
      "timestamp": 1555943751
    }
  }gpg: Signature made Mon 22 Apr 2019 07:35:51 AM PDT
  gpg:                using RSA key 28B76E05B923888E
  gpg: Can't check signature: No public key

We can test "valid signature for sha over http with multi-key keyring"
with the same signature we use to test the single-official-key tests.
And I don't see the point of running a "valid signature for sha over
http with custom gpg key" test, when we don't have any clusters that
actually care about that particular key.  I'm keeping the simple key
for now, just because putting _some_ other key into the unified
keyring is necessary for the "with multi-key keyring" tests.

[1]: https://www.rfc-editor.org/info/rfc4880/#section-5.2
[2]: https://www.rfc-editor.org/info/rfc9580/#signature-packet
wking added a commit to wking/openshift-library-go that referenced this pull request Nov 24, 2026
The 2007 RFC 4880 encouraged consumer support [1]:

  Implementations SHOULD accept V3 signatures. Implementations SHOULD
  generate V4 signatures.

The 2024 RFC 9580 tightens down against creating new v3 signatures,
and leaves it more open-ended about whether consuming v3 signatures is
a good idea [2]:

  Implementations MUST NOT create version 3 signatures; they MAY
  accept version 3 signatures.

Within OpenShift, the transition from v3 signatures to v4 signatures
happened somewhere during 2023:

  $ for Y in $(seq 3 22); do oc image info -o json "quay.io/openshift-release-dev/ocp-release:4.${Y}.0-x86_64" | jq -r '.config.created + " " + .digest' | while read CREATED DIGEST; do echo -n "4.${Y}.0 ${CREATED} ${DIGEST} "; curl -s "https://mirror.openshift.com/pub/openshift-v4/signatures/openshift/release/${DIGEST/:/=}/signature-1" | gpg --list-packets | grep -A1 'signature packet'; done; done
  4.3.0 2020-01-22T02:05:15Z sha256:3a516480dfd68e0f87f702b4d7bdd6f6a0acfdac5cd2e9767b838ceede34d70d :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 3, created 1579666968, md5len 5, sigclass 0x00
  4.4.0 2020-04-29T13:48:30Z sha256:96cb606d04e94de1954a50ddb965eb02b76e182478bef9225df0ad523cfa6b38 :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 3, created 1588175151, md5len 5, sigclass 0x00
  ...
  4.13.0 2023-05-16T10:09:04Z sha256:74b23ed4bbb593195a721373ed6693687a9b444c97065ce8ac653ba464375711 :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 3, created 1684251879, md5len 5, sigclass 0x00
  4.14.0 2023-10-26T14:31:15Z sha256:e2c70fca183e380c6121a1c847806f11e839482123277235a8579db472b9ccf2 :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 4, created 1698363623, md5len 0, sigclass 0x00
  ...
  4.22.0 2026-06-04T22:31:25Z sha256:283887f2860a745387608d106e70e5be2314df2497ee08c69e7bc669ca091340 :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 4, created 1780635619, md5len 0, sigclass 0x00

So we can safely drop the v3 support here, without breaking anything
trying to parse remotely-modern release signatures.

I'm also dropping the v3 registry.access.redhat.com/rhel7:7.6
signature we'd been using since the initial package commit c43c2cb
(Create a resuable verify package for image release verification,
2020-07-16, openshift#837), descended in turn from
openshift/cluster-version-operator@55e3cb450f (verifier: Add public
key verification of release image digests, 2019-04-20,
openshift/cluster-version-operator#170):

  $ gpg --list-packets < 'pkg/verify/testdata/signatures/sha256=e3f12513a4b22a2d7c0e7c9207f52128113758d9d68c7d06b11a0ac7672966f7/signature-1'
  # off=0 ctb=a3 tag=8 hlen=1 plen=0 indeterminate
  :compressed packet: algo=1
  # off=2 ctb=90 tag=4 hlen=2 plen=13
  :onepass_sig packet: keyid 199E2F91FD431D51
  	version 3, sigclass 0x00, digest 8, pubkey 1, last=1
  # off=17 ctb=ad tag=11 hlen=3 plen=324
  :literal data packet:
  	mode b (62), created 1554833664, name="_rpmsig-req-KOr4fw.bin",
  	raw data: 296 bytes
  # off=344 ctb=89 tag=2 hlen=3 plen=533
  :signature packet: algo 1, keyid 199E2F91FD431D51
  	version 3, created 1554833664, md5len 5, sigclass 0x00
  	digest algo 8, begin of digest 34 f2
  	data: [4095 bits]
  $ gpg --decrypt <pkg/verify/testdata/signatures/sha256\=e3f12513a4b22a2d7c0e7c9207f52128113758d9d68c7d06b11a0ac7672966f7/signature-1  | jq .
  gpg: Signature made Tue 09 Apr 2019 11:14:24 AM PDT
  gpg:                using RSA key 199E2F91FD431D51
  gpg: Good signature from "Red Hat, Inc. (release key 2) <[email protected]>" [unknown]
  gpg: WARNING: This key is not certified with a trusted signature!
  gpg:          There is no indication that the signature belongs to the owner.
  Primary key fingerprint: 567E 347A D004 4ADE 55BA  8A5F 199E 2F91 FD43 1D51
  {
    "critical": {
      "image": {
        "docker-manifest-digest": "sha256:e3f12513a4b22a2d7c0e7c9207f52128113758d9d68c7d06b11a0ac7672966f7"
      },
      "type": "atomic container signature",
      "identity": {
        "docker-reference": "registry.access.redhat.com/rhel7:7.6"
      }
    },
    "optional": {
      "creator": "Red Hat RCM Pub 0.35.0-final "
    }
  }

Instead, I'm using the OpenPGP v4 signature formatted 4.14.0
signature:

  $ curl -s 'https://mirror.openshift.com/pub/openshift-v4/signatures/openshift/release/sha256=e2c70fca183e380c6121a1c847806f11e839482123277235a8579db472b9ccf2/signature-1' > 'pkg/verify/testdata/signatures/sha256=e2c70fca183e380c6121a1c847806f11e839482123277235a8579db472b9ccf2/signature-1'

I'm also dropping (this time without replacement) the old
release-controller signature we'd also been dragging around since
Clayton's 2019 commit:

  $ gpg --list-packets pkg/verify/testdata/signatures/sha256=edd9824f0404f1a139688017e7001370e2f3fbc088b94da84506653b473fe140/signature-1
  # off=0 ctb=c4 tag=4 hlen=2 plen=13 new-ctb
  :onepass_sig packet: keyid 28B76E05B923888E
  	version 3, sigclass 0x00, digest 8, pubkey 1, last=1
  # off=15 ctb=cb tag=11 hlen=2 plen=0 partial new-ctb
  :literal data packet:
  	mode t (74), created 0, name="",
  	raw data: unknown length
  $ gpg --decrypt pkg/verify/testdata/signatures/sha256=edd9824f0404f1a139688017e7001370e2f3fbc088b94da84506653b473fe140/signature-1
  {
    "critical": {
      "type": "atomic container signature",
      "image": {
        "docker-manifest-digest": "sha256:edd9824f0404f1a139688017e7001370e2f3fbc088b94da84506653b473fe140"
      },
      "identity": {
        "docker-reference": "registry.svc.ci.openshift.org/ocp/release:4.0.0-0.ci-2019-04-19-181452"
      }
    },
    "optional": {
      "creator": "openshift release-controller",
      "timestamp": 1555943751
    }
  }gpg: Signature made Mon 22 Apr 2019 07:35:51 AM PDT
  gpg:                using RSA key 28B76E05B923888E
  gpg: Can't check signature: No public key

We can test "valid signature for sha over http with multi-key keyring"
with the same signature we use to test the single-official-key tests.
And I don't see the point of running a "valid signature for sha over
http with custom gpg key" test, when we don't have any clusters that
actually care about that particular key.  I'm keeping the simple key
for now, just because putting _some_ other key into the unified
keyring is necessary for the "with multi-key keyring" tests.

[1]: https://www.rfc-editor.org/info/rfc4880/#section-5.2
[2]: https://www.rfc-editor.org/info/rfc9580/#signature-packet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants