Skip to content

Commit 98fbbae

Browse files
committed
tests: add fips.enable.https
To verify that using TLS works in FIPS mode by having Ignition fetch a remote resource over HTTPS with FIPS compatible algorithms. tests/containers: setup nginx only serves files over HTTPS with FIPS compatible algorithms. Fixes https://issues.redhat.com/browse/COS-3487
1 parent c6612bc commit 98fbbae

4 files changed

Lines changed: 191 additions & 0 deletions

File tree

mantle/kola/tests/fips/fips.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,70 @@ func init() {
140140
}
141141
}`),
142142
})
143+
// Test that using TLS works in FIPS mode by having Ignition fetch
144+
// a remote resource over HTTPS with FIPS compatible algorithms.
145+
// See https://issues.redhat.com/browse/COS-3487
146+
// Note that 34.136.148.229 (on GCP) is an HTTPS server powered by
147+
// nginx, delivering a small file exclusively over HTTPS using
148+
// FIPS-compliant algorithms.
149+
register.RegisterTest(&register.Test{
150+
Run: fipsEnableTest,
151+
ClusterSize: 1,
152+
Name: `fips.enable.https`,
153+
Description: "Verify that fips enabled works if fetching a remote resource over HTTPS with FIPS compatible algorithms.",
154+
Flags: []register.Flag{},
155+
Tags: []string{kola.NeedsInternetTag},
156+
Distros: []string{"rhcos"},
157+
Platforms: []string{"qemu"},
158+
UserData: conf.Ignition(`{
159+
"ignition": {
160+
"config": {
161+
"replace": {
162+
"source": null,
163+
"verification": {}
164+
}
165+
},
166+
"security": {
167+
"tls": {
168+
"certificateAuthorities": [
169+
{
170+
"compression": "gzip",
171+
"source": "data:;base64,H4sIAAAAAAAC/2SUyc67SBLE7zzF3NEIDMY2h/+hirUwYAqzGG4Ym93sUJinH33f9KW78/hLKZQpRcR/fwYqGrL/Iymuh1QkAU/5pZSFkGJUkgS6Uw4IgiBHfphDf1ec6UuCl7glnBA2aSZXtM8rRMaRce1iVKypDbBiUhADou/Ky4KTBg6+Agjx3brB/hf6nmrlgRbsLwl68cPg4gciepHaVhURaweCJacsZcuIC3/g/gu5H/jLKpBZLks0EskBxrIMXe0eQA+prvUjH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tl3a0G3rLlXI8e9VaWbokE6vvDW2lhyVXSuGUI5HfrF7cjCkbTFEYWJugJWLe7Cl4h81tEY/z1kZUW/F8dJkekTKLGS1gWXJ2+vkuDFX3xm6bAsN4Sbsz6A9P3Phw55E5ztZZ79TpSLNAofbMVLubdwZtGOrgzx/qt6wVW/53gf8vAAD///rvDevdBQAA"
172+
}
173+
]
174+
}
175+
},
176+
"timeouts": {},
177+
"version": "3.4.0"
178+
},
179+
"passwd": {},
180+
"storage": {
181+
"files": [
182+
{
183+
"group": {
184+
"name": "root"
185+
},
186+
"overwrite": true,
187+
"path": "/etc/ignition-machine-config-encapsulated.json",
188+
"user": {
189+
"name": "root"
190+
},
191+
"contents": {
192+
"source": "data:,%7B%22metadata%22%3A%7B%22name%22%3A%22rendered-worker-1cc576110e0cf8396831ce4016f63900%22%2C%22selfLink%22%3A%22%2Fapis%2Fmachineconfiguration.openshift.io%2Fv1%2Fmachineconfigs%2Frendered-worker-1cc576110e0cf8396831ce4016f63900%22%2C%22uid%22%3A%2248871c03-899d-4332-a5f5-bef94e54b23f%22%2C%22resourceVersion%22%3A%224168%22%2C%22generation%22%3A1%2C%22creationTimestamp%22%3A%222019-11-04T15%3A54%3A08Z%22%2C%22annotations%22%3A%7B%22machineconfiguration.openshift.io%2Fgenerated-by-controller-version%22%3A%22bd846958bc95d049547164046a962054fca093df%22%7D%2C%22ownerReferences%22%3A%5B%7B%22apiVersion%22%3A%22machineconfiguration.openshift.io%2Fv1%22%2C%22kind%22%3A%22MachineConfigPool%22%2C%22name%22%3A%22worker%22%2C%22uid%22%3A%223d0dee9e-c9d6-4656-a4a9-81785b9ab01a%22%2C%22controller%22%3Atrue%2C%22blockOwnerDeletion%22%3Atrue%7D%5D%7D%2C%22spec%22%3A%7B%22osImageURL%22%3A%22registry.svc.ci.openshift.org%2Focp%2F4.3-2019-11-04-125204%40sha256%3A8a344c5b157bd01c3ca1abfcef0004fc39f5d69cac1cdaad0fd8dd332ad8e272%22%2C%22config%22%3A%7B%22ignition%22%3A%7B%22config%22%3A%7B%7D%2C%22security%22%3A%7B%22tls%22%3A%7B%7D%7D%2C%22timeouts%22%3A%7B%7D%2C%22version%22%3A%223.0.0%22%7D%2C%22networkd%22%3A%7B%7D%2C%22passwd%22%3A%7B%7D%2C%22storage%22%3A%7B%7D%2C%22systemd%22%3A%7B%7D%7D%2C%22kernelArguments%22%3A%5B%5D%2C%22fips%22%3Atrue%7D%7D",
193+
"verification": {}
194+
},
195+
"mode": 420
196+
},
197+
{
198+
"path": "/var/resource/https-fips",
199+
"contents": {
200+
"source": "https://34.136.148.229:8443/index.html"
201+
}
202+
}
203+
]
204+
}
205+
}`),
206+
})
143207
}
144208

145209
// Test: Run basic FIPS test
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM quay.io/fedora/fedora:43
2+
3+
RUN dnf install -y nginx && dnf clean all
4+
5+
COPY nginx.conf /etc/nginx/nginx.conf
6+
COPY index.html /usr/share/nginx/html/index.html
7+
8+
# TLS material
9+
COPY fips-server.crt /etc/nginx/tls/fips-server.crt
10+
COPY fips-server.key /etc/nginx/tls/fips-server.key
11+
12+
RUN chmod 600 /etc/nginx/tls/fips-server.key
13+
14+
EXPOSE 8443
15+
16+
CMD ["nginx", "-g", "daemon off;"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# fips-nginx Container
2+
3+
This is used by the `fips.enable.https` test to verify that using
4+
TLS works in FIPS mode by having Ignition fetch a remote resource
5+
over HTTPS with FIPS compatible algorithms.
6+
7+
To build the container using command:
8+
`./build.sh <IP>`
9+
10+
To run the container image using command:
11+
`podman run -d --name fips-nginx -p 8443:8443 fips-nginx`
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env bash
2+
3+
# Run the image using command:
4+
# podman run -d --name fips-nginx -p 8443:8443 fips-nginx
5+
set -euo pipefail
6+
7+
# Check if argument is provided
8+
if [ $# -eq 0 ]; then
9+
echo "Error: Missing IP address argument"
10+
echo "Usage: $0 <ip-address>"
11+
exit 1
12+
fi
13+
14+
ip="$1"
15+
16+
cd "$(mktemp -d)"
17+
# Prepare openssl.cnf
18+
# The IP must point to an nginx server configured with FIPS-compliant ciphers
19+
cat <<SSLEOF > openssl.cnf
20+
[ req ]
21+
default_bits = 3072
22+
distinguished_name = dn
23+
prompt = no
24+
string_mask = utf8only
25+
req_extensions = req_ext
26+
27+
[ dn ]
28+
CN = FIPS TLS Test Server
29+
30+
[ req_ext ]
31+
keyUsage = critical, digitalSignature, keyEncipherment
32+
extendedKeyUsage = critical, serverAuth
33+
subjectAltName = @alt_names
34+
35+
[ alt_names ]
36+
IP.1 = ${ip}
37+
SSLEOF
38+
39+
# Prepare index.html
40+
cat <<EOF > index.html
41+
This file was served from an RHCOS FIPS-hardened server.
42+
EOF
43+
44+
# Prepare nginx.conf
45+
cat <<EOF > nginx.conf
46+
events {}
47+
48+
http {
49+
server {
50+
listen 8443 ssl;
51+
server_name _;
52+
53+
# ---- FIPS-only TLS ----
54+
ssl_protocols TLSv1.2;
55+
ssl_prefer_server_ciphers on;
56+
57+
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256;
58+
59+
ssl_certificate /etc/nginx/tls/fips-server.crt;
60+
ssl_certificate_key /etc/nginx/tls/fips-server.key;
61+
62+
location / {
63+
root /usr/share/nginx/html;
64+
index index.html;
65+
}
66+
}
67+
}
68+
EOF
69+
70+
# Prepare key and crt
71+
## Generate the private key (FIPS-approved)
72+
openssl genpkey \
73+
-algorithm RSA \
74+
-pkeyopt rsa_keygen_bits:3072 \
75+
-out fips-server.key
76+
77+
## Generate CSR (still FIPS-only)
78+
openssl req -new -key fips-server.key -out fips-server.csr -config openssl.cnf
79+
80+
## Self-sign the certificate (TLS-compatible + FIPS)
81+
openssl x509 -req \
82+
-in fips-server.csr \
83+
-signkey fips-server.key \
84+
-out fips-server.crt \
85+
-days 3650 \
86+
-sha256 \
87+
-extfile openssl.cnf \
88+
-extensions req_ext
89+
90+
# Verify SAN present
91+
openssl x509 -in fips-server.crt -noout -text | grep -A2 "Subject Alternative Name"
92+
93+
openssl verify \
94+
-provider fips \
95+
-CAfile fips-server.crt \
96+
fips-server.crt
97+
98+
rm fips-server.csr openssl.cnf
99+
100+
podman build -t fips-nginx .

0 commit comments

Comments
 (0)