Skip to content

Commit 9145b48

Browse files
committed
RPM: Allow RH image verification on Fedora and CentOS Stream
This commit fetches the RH sigstore and rekor keys and also updates `/etc/containers/policy.json` to ensure image signature verification using said keys. Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent 397182c commit 9145b48

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

common/rpm/containers-common.spec

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,16 @@ Suggests: fuse-overlayfs
4545
URL: https://github.com/%{project}/%{repo}
4646
Source0: %{url}/archive/refs/tags/common/v%{version}.tar.gz
4747
Source1: https://raw.githubusercontent.com/containers/shortnames/refs/heads/main/shortnames.conf
48-
# Fetch RPM-GPG-KEY-redhat-release from the authoritative source instead of storing
49-
# a copy in repo or dist-git. Depending on distribution-gpg-keys rpm is also
50-
# not an option because that package doesn't exist on CentOS Stream.
48+
# Fetch Red Hat keys from the authoritative source instead of storing a copy in
49+
# repo or dist-git. Depending on distribution-gpg-keys is also not an option
50+
# because that package doesn't exist on CentOS Stream and/or it may not ship the
51+
# keys we need.
52+
# RPM-GPG-KEY-redhat-release
5153
Source2: https://access.redhat.com/security/data/fd431d51.txt
54+
# SIGSTORE-redhat-release3
55+
Source3: https://security.access.redhat.com/data/63405576.txt
56+
# REKOR-signing-key
57+
# Source4
5258

5359
%description
5460
This package contains common configuration files and documentation for container
@@ -107,14 +113,15 @@ touch %{buildroot}%{_prefix}/lib/containers/storage/overlay-layers/layers.lock
107113

108114
install -Dp -m0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/containers/registries.conf.d/000-shortnames.conf
109115
install -Dp -m0644 image/default.yaml %{buildroot}%{_sysconfdir}/containers/registries.d/default.yaml
110-
install -Dp -m0644 image/default-policy.json %{buildroot}%{_sysconfdir}/containers/policy.json
116+
install -Dp -m0644 common/rpm/policy.json %{buildroot}%{_sysconfdir}/containers/policy.json
111117
install -Dp -m0644 image/registries.conf %{buildroot}%{_sysconfdir}/containers/registries.conf
112118
install -Dp -m0644 storage/storage.conf %{buildroot}%{_datadir}/containers/storage.conf
113119

114-
# RPM-GPG-KEY-redhat-release already exists on rhel envs, install only on
120+
# These keys already exist on rhel envs, install only on
115121
# fedora and centos
116122
%if %{defined fedora} || %{defined centos}
117123
install -Dp -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
124+
install -Dp -m0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/pki/sigstore/SIGSTORE-redhat-release3
118125
%endif
119126

120127
install -Dp -m0644 common/contrib/redhat/registry.access.redhat.com.yaml -t %{buildroot}%{_sysconfdir}/containers/registries.d
@@ -162,6 +169,7 @@ ln -s ../../../..%{_sysconfdir}/yum.repos.d/redhat.repo %{buildroot}%{_datadir}/
162169
%config(noreplace) %{_sysconfdir}/containers/registries.conf.d/000-shortnames.conf
163170
%if 0%{?fedora} || 0%{?centos}
164171
%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
172+
%{_sysconfdir}/pki/sigstore/SIGSTORE-redhat-release3
165173
%endif
166174
%config(noreplace) %{_sysconfdir}/containers/registries.d/default.yaml
167175
%config(noreplace) %{_sysconfdir}/containers/registries.d/registry.redhat.io.yaml

common/rpm/policy.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"default": [
3+
{
4+
"type": "insecureAcceptAnything"
5+
}
6+
],
7+
"transports": {
8+
"docker": {
9+
"registry.access.redhat.com": [
10+
{
11+
"type": "sigstoreSigned",
12+
"keyPath": "/etc/pki/sigstore/SIGSTORE-redhat-release3",
13+
"rekorPublicKeyPath": "/etc/pki/sigstore/REKOR-signing-key"
14+
}
15+
],
16+
"registry.redhat.io": [
17+
{
18+
"type": "sigstoreSigned",
19+
"keyPath": "/etc/pki/sigstore/SIGSTORE-redhat-release3",
20+
"rekorPublicKeyPath": "/etc/pki/sigstore/REKOR-signing-key"
21+
}
22+
]
23+
},
24+
"docker-daemon": {
25+
"": [
26+
{
27+
"type": "insecureAcceptAnything"
28+
}
29+
]
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)