-
Notifications
You must be signed in to change notification settings - Fork 141
387 lines (312 loc) · 12.8 KB
/
server-https-nss-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
name: HTTPS connector with NSS database
on: workflow_call
env:
DS_IMAGE: ${{ vars.DS_IMAGE || 'quay.io/389ds/dirsrv' }}
jobs:
# docs/admin/server/Configuring-HTTPS-Connector-with-NSS-Database.adoc
test:
name: Test
runs-on: ubuntu-latest
env:
SHARED: /tmp/workdir/pki
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Retrieve PKI images
uses: actions/cache@v4
with:
key: pki-images-${{ github.sha }}
path: pki-images.tar
- name: Load PKI images
run: docker load --input pki-images.tar
- name: Create network
run: docker network create example
- name: Set up server container
run: |
tests/bin/runner-init.sh pki
env:
HOSTNAME: pki.example.com
- name: Connect server container to network
run: docker network connect example pki --alias pki.example.com --alias server.example.com
- name: Create PKI server
run: |
docker exec pki pki-server create -v
- name: Create NSS database in PKI server
run: |
docker exec pki pki-server nss-create --no-password
- name: Create CA signing cert
run: |
# generate CA signing CSR
docker exec pki pki \
-d /var/lib/pki/pki-tomcat/alias \
nss-cert-request \
--subject "CN=CA Signing Certificate" \
--ext /usr/share/pki/server/certs/ca_signing.conf \
--csr $SHARED/ca_signing.csr
# create CA signing cert
docker exec pki pki \
-d /var/lib/pki/pki-tomcat/alias \
nss-cert-issue \
--csr $SHARED/ca_signing.csr \
--ext /usr/share/pki/server/certs/ca_signing.conf \
--validity-length 1 \
--validity-unit year \
--cert $SHARED/ca_signing.crt
# check CA signing cert
openssl x509 -text -noout -in ca_signing.crt
# import CA signing cert
docker exec pki pki \
-d /var/lib/pki/pki-tomcat/alias \
nss-cert-import \
--cert $SHARED/ca_signing.crt \
--trust CT,C,C \
ca_signing
# check CA signing cert
docker exec pki pki \
-d /var/lib/pki/pki-tomcat/alias \
nss-cert-show \
ca_signing
- name: Create SSL server cert
run: |
# generate SSL server CSR
docker exec pki pki \
-d /var/lib/pki/pki-tomcat/alias \
nss-cert-request \
--subject "CN=pki.example.com" \
--ext /usr/share/pki/server/certs/sslserver.conf \
--csr $SHARED/sslserver.csr
# issue SSL server cert that expires in 2 minutes
docker exec pki pki \
-d /var/lib/pki/pki-tomcat/alias \
nss-cert-issue \
--issuer ca_signing \
--csr $SHARED/sslserver.csr \
--ext /usr/share/pki/server/certs/sslserver.conf \
--validity-length 2 \
--validity-unit minute \
--cert $SHARED/sslserver.crt
# check SSL server cert
openssl x509 -text -noout -in sslserver.crt
# import SSL server cert
docker exec pki pki \
-d /var/lib/pki/pki-tomcat/alias \
nss-cert-import \
--cert $SHARED/sslserver.crt \
sslserver
- name: Create HTTPS connector with NSS database
run: |
docker exec pki pki-server jss-enable
docker exec pki pki-server http-connector-add \
--port 8443 \
--scheme https \
--secure true \
--sslEnabled true \
--sslProtocol SSL \
--sslImpl org.dogtagpki.jss.tomcat.JSSImplementation \
Secure
docker exec pki pki-server http-connector-cert-add \
--keyAlias sslserver \
--keystoreType pkcs11 \
--keystoreProvider Mozilla-JSS
- name: Deploy webapps
run: |
docker exec pki pki-server webapp-deploy \
--descriptor /usr/share/pki/server/conf/Catalina/localhost/ROOT.xml \
ROOT
docker exec pki pki-server webapp-deploy \
--descriptor /usr/share/pki/server/conf/Catalina/localhost/pki.xml \
pki
- name: Start PKI server
run: |
docker exec pki pki-server start
- name: Set up client container
run: |
tests/bin/runner-init.sh client
env:
HOSTNAME: client.example.com
- name: Connect client container to network
run: docker network connect example client --alias client.example.com
- name: Wait for PKI server to start
run: |
docker exec client curl \
--retry 60 \
--retry-delay 0 \
--retry-connrefused \
-s \
-k \
-o /dev/null \
https://pki.example.com:8443
- name: Check PKI CLI with unknown issuer
run: |
# run PKI CLI but don't trust the cert
echo n | docker exec -i client pki \
-D org.dogtagpki.client.socketFactory=org.dogtagpki.client.NonBlockingSocketFactory \
-U https://pki.example.com:8443 \
info \
> >(tee stdout) 2> >(tee stderr >&2) || true
# check stdout
cat > expected << EOF
Server URL: https://pki.example.com:8443
EOF
diff expected stdout
# check stderr
cat > expected << EOF
WARNING: UNKNOWN_ISSUER encountered on 'CN=pki.example.com' indicates an unknown CA cert 'CN=CA Signing Certificate'
Trust this certificate (y/N)? IOException: Unable to write to socket: Unable to validate CN=pki.example.com: Unknown issuer: CN=CA Signing Certificate
EOF
# TODO: Update the expected stderr once the missing SSL alert is fixed
# Trust this certificate (y/N)? SEVERE: FATAL: SSL alert sent: UNKNOWN_CA
# IOException: Unable to write to socket: Unable to validate CN=pki.example.com: Unknown issuer: CN=CA Signing Certificate
diff expected stderr
# the cert should not be stored
docker exec client pki nss-cert-find --subject CN=pki.example.com | tee output
diff /dev/null output
- name: Check PKI CLI with unknown issuer with wrong hostname
run: |
# run PKI CLI with wrong hostname
echo n | docker exec -i client pki \
-D org.dogtagpki.client.socketFactory=org.dogtagpki.client.NonBlockingSocketFactory \
-U https://server.example.com:8443 \
info \
> >(tee stdout) 2> >(tee stderr >&2) || true
# check stdout
cat > expected << EOF
Server URL: https://server.example.com:8443
EOF
diff expected stdout
# check stderr
cat > expected << EOF
WARNING: BAD_CERT_DOMAIN encountered on 'CN=pki.example.com' indicates a common-name mismatch
WARNING: UNKNOWN_ISSUER encountered on 'CN=pki.example.com' indicates an unknown CA cert 'CN=CA Signing Certificate'
Trust this certificate (y/N)? IOException: Unable to write to socket: Unable to validate CN=pki.example.com: Bad certificate domain: CN=pki.example.com
EOF
# TODO: Update the expected stderr once the missing SSL alert is fixed
# Trust this certificate (y/N)? SEVERE: FATAL: SSL alert sent: ACCESS_DENIED
# IOException: Unable to write to socket: Unable to validate CN=pki.example.com: Bad certificate domain: CN=pki.example.com
diff expected stderr
# the cert should not be stored
docker exec client pki nss-cert-find --subject CN=pki.example.com | tee output
diff /dev/null output
- name: Check PKI CLI with newly trusted server cert
run: |
# run PKI CLI and trust the cert
echo y | docker exec -i client pki \
-D org.dogtagpki.client.socketFactory=org.dogtagpki.client.NonBlockingSocketFactory \
-U https://pki.example.com:8443 \
info \
> >(tee stdout) 2> >(tee stderr >&2) || true
# check stdout
cat > expected << EOF
Server URL: https://pki.example.com:8443
Server Name: Dogtag Certificate System
Server Version: 11.6.0
EOF
diff expected stdout
# check stderr
cat > expected << EOF
WARNING: UNKNOWN_ISSUER encountered on 'CN=pki.example.com' indicates an unknown CA cert 'CN=CA Signing Certificate'
Trust this certificate (y/N)?
EOF
# remove trailing whitespace
sed -i 's/ *$//' stderr
# append end of line
echo >> stderr
diff expected stderr
# the cert should be stored and trusted
docker exec client pki nss-cert-find --subject CN=pki.example.com | tee output
sed -i \
-e '/^ *Serial Number:/d' \
-e '/^ *Not Valid Before:/d' \
-e '/^ *Not Valid After:/d' \
output
cat > expected << EOF
Nickname: CN=pki.example.com
Subject DN: CN=pki.example.com
Issuer DN: CN=CA Signing Certificate
Trust Flags: P,,
EOF
diff expected output
- name: Check PKI CLI with trusted server cert with wrong hostname
run: |
# run PKI CLI with wrong hostname
docker exec client pki \
-D org.dogtagpki.client.socketFactory=org.dogtagpki.client.NonBlockingSocketFactory \
-U https://server.example.com:8443 \
info \
> >(tee stdout) 2> >(tee stderr >&2) || true
# check stdout
cat > expected << EOF
Server URL: https://server.example.com:8443
Server Name: Dogtag Certificate System
Server Version: 11.6.0
EOF
diff expected stdout
# check stderr
cat > expected << EOF
WARNING: BAD_CERT_DOMAIN encountered on 'CN=pki.example.com' indicates a common-name mismatch
EOF
diff expected stderr
- name: Check PKI CLI with already trusted server cert
run: |
# run PKI CLI with correct hostname
docker exec client pki \
-D org.dogtagpki.client.socketFactory=org.dogtagpki.client.NonBlockingSocketFactory \
-U https://pki.example.com:8443 \
info \
> >(tee stdout) 2> >(tee stderr >&2) || true
# check stdout
cat > expected << EOF
Server URL: https://pki.example.com:8443
Server Name: Dogtag Certificate System
Server Version: 11.6.0
EOF
diff expected stdout
# check stderr
diff /dev/null stderr
- name: Check PKI CLI with expired server cert
run: |
sleep 120
docker exec client pki \
-D org.dogtagpki.client.socketFactory=org.dogtagpki.client.NonBlockingSocketFactory \
-U https://pki.example.com:8443 \
info \
> >(tee stdout) 2> >(tee stderr >&2) || true
# check stdout
cat > expected << EOF
Server URL: https://pki.example.com:8443
EOF
diff expected stdout
# check stderr
cat > expected << EOF
ERROR: EXPIRED_CERTIFICATE encountered on 'CN=pki.example.com' results in a denied SSL server cert!
IOException: Unable to write to socket: Unable to validate CN=pki.example.com: Expired certificate: CN=pki.example.com
EOF
# TODO: Update the expected stderr once the missing SSL alert is fixed
# SEVERE: FATAL: SSL alert sent: CERTIFICATE_EXPIRED
diff expected stderr
- name: Stop PKI server
run: |
docker exec pki pki-server stop --wait -v
- name: Remove PKI server
run: |
docker exec pki pki-server remove -v
- name: Check PKI server systemd journal
if: always()
run: |
docker exec pki journalctl -x --no-pager -u [email protected]
- name: Check PKI debug log
if: always()
run: |
docker exec pki find /var/lib/pki/pki-tomcat/logs/pki -name "debug.*" -exec cat {} \;
- name: Gather artifacts from server container
if: always()
run: |
tests/bin/pki-artifacts-save.sh pki
continue-on-error: true
- name: Upload artifacts from server container
if: always()
uses: actions/upload-artifact@v4
with:
name: server-https-nss-test
path: |
/tmp/artifacts/pki