Skip to content

Commit 52a97ec

Browse files
authored
feat: create persistent secure boot test keys for easier downstream builds (#45)
1 parent 9f1b0a4 commit 52a97ec

8 files changed

+58
-28
lines changed

.github/workflows/build.yml

+1-10
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,7 @@ jobs:
116116
run: |
117117
mkdir -p certs
118118
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
119-
openssl req -new \
120-
-nodes \
121-
-utf8 \
122-
-sha256 \
123-
-days 365 \
124-
-batch \
125-
-x509 \
126-
-outform DER \
127-
-out certs/public_key.der \
128-
-keyout certs/private_key.priv
119+
echo "Using test signing key"
129120
else
130121
echo "${{ secrets.AKMOD_PRIVKEY }}" > certs/private_key.priv
131122
fi

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
certs/private_key.priv
1+
certs/private_key.priv.prod
2+
certs/public_key.der.prod

Containerfile

+8-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ RUN rpm-ostree install \
2727
# alternatives cannot create symlinks on its own during a container build
2828
RUN ln -s /usr/bin/ld.bfd /etc/alternatives/ld && ln -s /etc/alternatives/ld /usr/bin/ld
2929

30-
ADD certs/public_key.der /etc/pki/akmods/certs/public_key.der
31-
ADD certs/private_key.priv /etc/pki/akmods/private/private_key.priv
30+
ADD certs /tmp/certs
3231

33-
RUN chmod 644 /etc/pki/akmods/{private/private_key.priv,certs/public_key.der}
32+
RUN [[ -s "/tmp/certs/private_key.priv" ]] || \
33+
echo "WARNING: Using test signing key. Run './generate-akmods-key' for production builds." && \
34+
cp /tmp/certs/private_key.priv{.test,} && \
35+
cp /tmp/certs/public_key.der{.test,}
36+
37+
RUN install -Dm644 /tmp/certs/public_key.der /etc/pki/akmods/certs/public_key.der
38+
RUN install -Dm644 /tmp/certs/private_key.priv /etc/pki/akmods/private/private_key.priv
3439

3540
# Either successfully build and install the kernel modules, or fail early with debug output
3641
RUN NVIDIA_PACKAGE_NAME="$(cat /tmp/nvidia-package-name.txt)" \

README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -82,36 +82,38 @@ If you're forking this repo you should [read the docs](https://docs.github.com/e
8282
8383
## Building locally
8484
85-
1. Generate signing keys
85+
1. Build container
8686
87-
Self-generated signing keys in `certs/` are required for kernel module signing to succeed:
88-
89-
```
90-
$ ./generate-akmod-key
91-
```
92-
93-
If you are forking this repo, you also need to add the private key to the repository secrets under the name AKMOD_PRIVKEY.
94-
95-
2. Build container
96-
97-
A container build can be invoked by simply running:
87+
A container build can be invoked by simply running:
9888
9989
```
10090
$ podman build \
10191
--file Containerfile \
10292
--tag build-test:latest
10393
```
10494
105-
Or to specify the version of Fedora and/or Nvidia driver:
95+
Or to specify the version of Fedora and/or Nvidia driver:
10696
10797
```
10898
$ podman build \
99+
--build-arg IMAGE_NAME=silverblue \
109100
--build-arg FEDORA_MAJOR_VERSION=37 \
110101
--build-arg NVIDIA_MAJOR_VERSION=525 \
111102
--file Containerfile \
112103
--tag build-test:latest
113104
```
114105
106+
2. Generate signing keys
107+
108+
If you are forking this repo, then you should add a private key to the repository secrets:
109+
110+
```
111+
$ ./generate-akmod-key
112+
$ gh secret set AKMOD_PRIVKEY < certs/private_key.priv.prod
113+
$ cp certs/public_key.der.prod certs/public_key.der
114+
```
115+
116+
115117
## Using Nvidia GPUs in containers
116118
117119
[There is support for enabling Nvidia GPUs in containers](https://www.redhat.com/en/blog/how-use-gpus-containers-bare-metal-rhel-8). This can can be verified by running the following:

certs/private_key.priv

Whitespace-only changes.

certs/private_key.priv.test

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-----BEGIN PRIVATE KEY-----
2+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDMaUcd1e4fYogO
3+
N/cYZc22xmzsAetfhgVLvHNkKb/mNHywkGK4T7vPwvpQCxFGUufmRxYlGJra/QCn
4+
WjYd4/thBWoU/K7RBcLJJpuHFBODls5eBdXGXXpeTYmRKq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oIPsLgjDtccMLIbFXDp6DP
21+
FWBORKJX958Xx033ANiN+ZQRfIr/8RuKn2ZVM9VL3tPV22ZnpMYh9j5AYQKBgF36
22+
+gGnJaN7aweMCRH3uORDJDoZjSTw0+/hf66EoBWN/68bnfjXNhCb7J+/oNntH0qB
23+
LpnqH3n1WAY9qhjusNmHwwJx7pF51fzRlvG3fZTlIWBpoSrwmI2TqQGnFLcJh36s
24+
mAz/jGLtqQMu21leRGC7ooYurBAOjcf3e5Al1mjhAoGAT0L02oGzce1vbwfqHCRK
25+
PexrY8GvNU6/Bml70P9n6FX3jQwt6Dhh1JkZZofv+wJWjOj4zV/Z0tj1uB1Ax9nR
26+
Z+87Pu7iYuNaYFGT9s76q+sbQtiUu5Gwlg6CyRSwbKdL15UBWf+Bt22Tp3NfbEoh
27+
OevJKeniH2GYy+ME5XxXb14=
28+
-----END PRIVATE KEY-----

certs/public_key.der.test

875 Bytes
Binary file not shown.

generate-akmods-key

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -oeux pipefail
44

5+
readonly LANG="${LANG:-en_US.UTF-8}"
6+
57
readonly CERT_DIR=certs
68

79
readonly IMAGE="quay.io/fedora-ostree-desktops/silverblue"
@@ -20,4 +22,5 @@ podman run \
2022
"sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/fedora-{cisco-openh264,modular,updates-modular,updates-archive}.repo && \
2123
rpm-ostree install akmods && \
2224
kmodgenca --auto && \
23-
cp /etc/pki/akmods/{private/private_key.priv,certs/public_key.der} ."
25+
cp /etc/pki/akmods/private/private_key.priv private_key.priv.prod && \
26+
cp /etc/pki/akmods/certs/public_key.der public_key.der.prod"

0 commit comments

Comments
 (0)