Skip to content

Commit 2a8d5b9

Browse files
jkuwoodruffw
andauthored
Backport trust root fixes to 3.5.x (#1578)
* Backport: internal/trust: Fix bug in rekor key lookup Rekor keyring can (and in future will) have multiple keys: logs not only get sharded but once rekor-tiles is integrated in the public good instance, there will be two writable logs for a while. Backport of #1350 Signed-off-by: Jussi Kukkonen <[email protected]> * Backport #1424 Fail less hard when unsupported keys are seen Current trusted root contains keys this client version does not understand: the keys are not necessary to verify or sign bundles with rekor v1 Signed-off-by: Jussi Kukkonen <[email protected]> * Backport: ci: fix offline tests on ubuntu-latest Backport of #1283 Signed-off-by: Jussi Kukkonen <[email protected]> * Bump 3.5.x series to 3.5.4 Signed-off-by: Jussi Kukkonen <[email protected]> --------- Signed-off-by: Jussi Kukkonen <[email protected]> Co-authored-by: William Woodruff <[email protected]>
1 parent 87ff7f1 commit 2a8d5b9

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ jobs:
4646
- name: test (offline)
4747
if: matrix.conf.os == 'ubuntu-latest'
4848
run: |
49+
# Look at me. I am the captain now.
50+
sudo sysctl -w kernel.unprivileged_userns_clone=1
51+
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
52+
4953
# We use `unshare` to "un-share" the default networking namespace,
5054
# in effect running the tests as if the host is offline.
5155
# This in turn effectively exercises the correctness of our
5256
# "online-only" test markers, since any test that's online
5357
# but not marked as such will fail.
54-
# We also explicitly exclude the intergration tests, since these are
58+
# We also explicitly exclude the integration tests, since these are
5559
# always online.
5660
unshare --map-root-user --net make test T="test/unit" TEST_ARGS="--skip-online -vv --showlocals"
5761

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ All versions prior to 0.9.0 are untracked.
88

99
## [Unreleased]
1010

11+
## [3.5.4]
12+
13+
### Fixed
14+
15+
* Do not fail hard if trust root contains unsupported keys
16+
(Backport of [#1424](https://github.com/sigstore/sigstore-python/pull/1424))
17+
* Fix bug in rekor key lookup
18+
(Backport of [#1350](https://github.com/sigstore/sigstore-python/pull/1350))
19+
1120
## [3.5.3]
1221

1322
### Fixed

sigstore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
* `sigstore.sign`: creation of Sigstore signatures
2626
"""
2727

28-
__version__ = "3.5.3"
28+
__version__ = "3.5.4"

sigstore/_internal/trust.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from __future__ import annotations
2020

21+
import logging
2122
from dataclasses import dataclass
2223
from datetime import datetime, timezone
2324
from enum import Enum
@@ -57,6 +58,8 @@
5758
)
5859
from sigstore.errors import Error, MetadataError, VerificationError
5960

61+
_logger = logging.getLogger(__name__)
62+
6063

6164
def _is_timerange_valid(period: TimeRange | None, *, allow_expired: bool) -> bool:
6265
"""
@@ -164,8 +167,11 @@ def __init__(self, public_keys: List[_PublicKey] = []):
164167
self._keyring: dict[KeyID, Key] = {}
165168

166169
for public_key in public_keys:
167-
key = Key(public_key)
168-
self._keyring[key.key_id] = key
170+
try:
171+
key = Key(public_key)
172+
self._keyring[key.key_id] = key
173+
except VerificationError as e:
174+
_logger.warning(f"Failed to load a trusted root key: {e}")
169175

170176
def verify(self, *, key_id: KeyID, signature: bytes, data: bytes) -> None:
171177
"""
@@ -333,8 +339,8 @@ def rekor_keyring(self, purpose: KeyringPurpose) -> RekorKeyring:
333339
"""Return keyring with keys for Rekor."""
334340

335341
keys: list[_PublicKey] = list(self._get_tlog_keys(self._inner.tlogs, purpose))
336-
if len(keys) != 1:
337-
raise MetadataError("Did not find one Rekor key in trusted root")
342+
if len(keys) == 0:
343+
raise MetadataError("Did not find any Rekor keys in trusted root")
338344
return RekorKeyring(Keyring(keys))
339345

340346
def ct_keyring(self, purpose: KeyringPurpose) -> CTKeyring:

0 commit comments

Comments
 (0)