-
Notifications
You must be signed in to change notification settings - Fork 139
341 lines (277 loc) · 12.5 KB
/
kra-cmc-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
name: KRA with CMC
on: workflow_call
env:
DS_IMAGE: ${{ vars.DS_IMAGE || 'quay.io/389ds/dirsrv' }}
jobs:
# docs/installation/kra/Installing_KRA_with_External_Certificates.md
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 CA DS container
run: |
tests/bin/ds-create.sh \
--image=${{ env.DS_IMAGE }} \
--hostname=cads.example.com \
--password=Secret.123 \
cads
- name: Connect CA DS container to network
run: docker network connect example cads --alias cads.example.com
- name: Set up CA container
run: |
tests/bin/runner-init.sh ca
env:
HOSTNAME: ca.example.com
- name: Connect CA container to network
run: docker network connect example ca --alias ca.example.com
- name: Install CA in CA container
run: |
docker exec ca pkispawn \
-f /usr/share/pki/server/examples/installation/ca.cfg \
-s CA \
-D pki_ds_url=ldap://cads.example.com:3389 \
-v
docker exec ca pki-server cert-find
- name: Initialize CA admin in CA container
run: |
docker exec ca pki-server cert-export ca_signing --cert-file $SHARED/ca_signing.crt
docker exec ca pki nss-cert-import \
--cert $SHARED/ca_signing.crt \
--trust CT,C,C \
ca_signing
docker exec ca pki pkcs12-import \
--pkcs12 /root/.dogtag/pki-tomcat/ca_admin_cert.p12 \
--pkcs12-password Secret.123
- name: Set up KRA DS container
run: |
tests/bin/ds-create.sh \
--image=${{ env.DS_IMAGE }} \
--hostname=krads.example.com \
--password=Secret.123 \
krads
- name: Connect KRA DS container to network
run: docker network connect example krads --alias krads.example.com
- name: Set up KRA container
run: |
tests/bin/runner-init.sh kra
env:
HOSTNAME: kra.example.com
- name: Connect KRA container to network
run: docker network connect example kra --alias kra.example.com
- name: Install KRA in KRA container (step 1)
run: |
docker exec kra pkispawn \
-f /usr/share/pki/server/examples/installation/kra-external-certs-step1.cfg \
-s KRA \
-D pki_cert_chain_path=$SHARED/ca_signing.crt \
-D pki_ds_url=ldap://krads.example.com:3389 \
-D pki_storage_csr_path=$SHARED/kra_storage.csr \
-D pki_transport_csr_path=$SHARED/kra_transport.csr \
-D pki_subsystem_csr_path=$SHARED/subsystem.csr \
-D pki_sslserver_csr_path=$SHARED/sslserver.csr \
-D pki_audit_signing_csr_path=$SHARED/kra_audit_signing.csr \
-D pki_admin_csr_path=$SHARED/kra_admin.csr \
-v
# https://github.com/dogtagpki/pki/wiki/Issuing-KRA-Storage-Certificate-with-CMC
- name: Issue KRA storage cert with CMC
run: |
# check cert request
docker exec ca openssl req -text -noout -in $SHARED/kra_storage.csr
# create CMC request
docker exec ca cp $SHARED/kra_storage.csr kra_storage.csr
docker exec ca CMCRequest \
/usr/share/pki/server/examples/cmc/kra_storage-cmc-request.cfg
# submit CMC request
docker exec ca HttpClient \
/usr/share/pki/server/examples/cmc/kra_storage-cmc-submit.cfg
# convert CMC response (DER PKCS #7) into PEM PKCS #7 cert chain
docker exec ca CMCResponse \
-d /root/.dogtag/nssdb \
-i kra_storage.cmc-response \
-o $SHARED/kra_storage.p7b
# check issued cert chain
docker exec ca openssl pkcs7 -print_certs -in $SHARED/kra_storage.p7b
# https://github.com/dogtagpki/pki/wiki/Issuing-KRA-Transport-Certificate-with-CMC
- name: Issue KRA transport cert with CMC
run: |
# check cert request
docker exec ca openssl req -text -noout -in $SHARED/kra_transport.csr
# create CMC request
docker exec ca cp $SHARED/kra_transport.csr kra_transport.csr
docker exec ca CMCRequest \
/usr/share/pki/server/examples/cmc/kra_transport-cmc-request.cfg
# submit CMC request
docker exec ca HttpClient \
/usr/share/pki/server/examples/cmc/kra_transport-cmc-submit.cfg
# convert CMC response (DER PKCS #7) into PEM PKCS #7 cert chain
docker exec ca CMCResponse \
-d /root/.dogtag/nssdb \
-i kra_transport.cmc-response \
-o $SHARED/kra_transport.p7b
# check issued cert chain
docker exec ca openssl pkcs7 -print_certs -in $SHARED/kra_transport.p7b
# https://github.com/dogtagpki/pki/wiki/Issuing-Subsystem-Certificate-with-CMC
- name: Issue subsystem cert with CMC
run: |
# check cert request
docker exec ca openssl req -text -noout -in $SHARED/subsystem.csr
# create CMC request
docker exec ca cp $SHARED/subsystem.csr subsystem.csr
docker exec ca CMCRequest \
/usr/share/pki/server/examples/cmc/subsystem-cmc-request.cfg
# submit CMC request
docker exec ca HttpClient \
/usr/share/pki/server/examples/cmc/subsystem-cmc-submit.cfg
# convert CMC response (DER PKCS #7) into PEM PKCS #7 cert chain
docker exec ca CMCResponse \
-d /root/.dogtag/nssdb \
-i subsystem.cmc-response \
-o $SHARED/subsystem.p7b
# check issued cert chain
docker exec ca openssl pkcs7 -print_certs -in $SHARED/subsystem.p7b
# https://github.com/dogtagpki/pki/wiki/Issuing-SSL-Server-Certificate-with-CMC
- name: Issue SSL server cert with CMC
run: |
# check cert request
docker exec ca openssl req -text -noout -in $SHARED/sslserver.csr
# create CMC request
docker exec ca cp $SHARED/sslserver.csr sslserver.csr
docker exec ca CMCRequest \
/usr/share/pki/server/examples/cmc/sslserver-cmc-request.cfg
# submit CMC request
docker exec ca HttpClient \
/usr/share/pki/server/examples/cmc/sslserver-cmc-submit.cfg
# convert CMC response (DER PKCS #7) into PEM PKCS #7 cert chain
docker exec ca CMCResponse \
-d /root/.dogtag/nssdb \
-i sslserver.cmc-response \
-o $SHARED/sslserver.p7b
# check issued cert chain
docker exec ca openssl pkcs7 -print_certs -in $SHARED/sslserver.p7b
# https://github.com/dogtagpki/pki/wiki/Issuing-Audit-Signing-Certificate-with-CMC
- name: Issue KRA audit signing cert with CMC
run: |
# check cert request
docker exec ca openssl req -text -noout -in $SHARED/kra_audit_signing.csr
# create CMC request
docker exec ca cp $SHARED/kra_audit_signing.csr audit_signing.csr
docker exec ca CMCRequest \
/usr/share/pki/server/examples/cmc/audit_signing-cmc-request.cfg
# submit CMC request
docker exec ca HttpClient \
/usr/share/pki/server/examples/cmc/audit_signing-cmc-submit.cfg
# convert CMC response (DER PKCS #7) into PEM PKCS #7 cert chain
docker exec ca CMCResponse \
-d /root/.dogtag/nssdb \
-i audit_signing.cmc-response \
-o $SHARED/kra_audit_signing.p7b
# check issued cert chain
docker exec ca openssl pkcs7 -print_certs -in $SHARED/kra_audit_signing.p7b
# https://github.com/dogtagpki/pki/wiki/Issuing-Admin-Certificate-with-CMC
- name: Issue KRA admin cert with CMC
run: |
# check cert request
docker exec ca openssl req -text -noout -in $SHARED/kra_admin.csr
# create CMC request
docker exec ca cp $SHARED/kra_admin.csr admin.csr
docker exec ca CMCRequest \
/usr/share/pki/server/examples/cmc/admin-cmc-request.cfg
# submit CMC request
docker exec ca HttpClient \
/usr/share/pki/server/examples/cmc/admin-cmc-submit.cfg
# convert CMC response (DER PKCS #7) into PEM PKCS #7 cert chain
docker exec ca CMCResponse \
-d /root/.dogtag/nssdb \
-i admin.cmc-response \
-o kra_admin.p7b
# pki_admin_cert_path only supports a single cert so the admin cert
# needs to be exported from the PKCS #7 cert chain
# TODO: fix pki_admin_cert_path to support PKCS #7 cert chain
docker exec ca pki pkcs7-cert-export \
--pkcs7 kra_admin.p7b \
--output-prefix kra_admin- \
--output-suffix .crt
docker exec ca cp kra_admin-1.crt $SHARED/kra_admin.crt
# check issued cert
docker exec ca openssl x509 -text -noout -in $SHARED/kra_admin.crt
- name: Install KRA in KRA container (step 2)
run: |
docker exec kra pkispawn \
-f /usr/share/pki/server/examples/installation/kra-external-certs-step2.cfg \
-s KRA \
-D pki_cert_chain_path=$SHARED/ca_signing.crt \
-D pki_ds_url=ldap://krads.example.com:3389 \
-D pki_storage_csr_path=$SHARED/kra_storage.csr \
-D pki_transport_csr_path=$SHARED/kra_transport.csr \
-D pki_subsystem_csr_path=$SHARED/subsystem.csr \
-D pki_sslserver_csr_path=$SHARED/sslserver.csr \
-D pki_audit_signing_csr_path=$SHARED/kra_audit_signing.csr \
-D pki_admin_csr_path=$SHARED/kra_admin.csr \
-D pki_storage_cert_path=$SHARED/kra_storage.p7b \
-D pki_transport_cert_path=$SHARED/kra_transport.p7b \
-D pki_subsystem_cert_path=$SHARED/subsystem.p7b \
-D pki_sslserver_cert_path=$SHARED/sslserver.p7b \
-D pki_audit_signing_cert_path=$SHARED/kra_audit_signing.p7b \
-D pki_admin_cert_path=$SHARED/kra_admin.crt \
-v
docker exec kra pki-server cert-find
# TODO: Fix DogtagKRAConnectivityCheck to work without CA
# - name: Run PKI healthcheck
# run: docker exec kra pki-healthcheck --failures-only
- name: Verify KRA admin
run: |
docker exec kra pki nss-cert-import \
--cert $SHARED/ca_signing.crt \
--trust CT,C,C \
ca_signing
docker exec kra pki pkcs12-import \
--pkcs12 /root/.dogtag/pki-tomcat/kra_admin_cert.p12 \
--pkcs12-password Secret.123
docker exec kra pki -n kraadmin kra-user-show kraadmin
- name: Remove KRA from KRA container
run: docker exec kra pkidestroy -s KRA -v
- name: Remove CA from CA container
run: docker exec ca pkidestroy -s CA -v
- name: Check PKI server systemd journal in CA container
if: always()
run: |
docker exec ca journalctl -x --no-pager -u [email protected]
- name: Check CA debug log
if: always()
run: |
docker exec ca find /var/lib/pki/pki-tomcat/logs/ca -name "debug.*" -exec cat {} \;
- name: Check PKI server systemd journal in KRA container
if: always()
run: |
docker exec kra journalctl -x --no-pager -u [email protected]
- name: Check KRA debug log
if: always()
run: |
docker exec kra find /var/lib/pki/pki-tomcat/logs/kra -name "debug.*" -exec cat {} \;
- name: Gather artifacts
if: always()
run: |
tests/bin/ds-artifacts-save.sh cads
tests/bin/pki-artifacts-save.sh ca
tests/bin/ds-artifacts-save.sh krads
tests/bin/pki-artifacts-save.sh kra
continue-on-error: true
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: kra-cmc
path: /tmp/artifacts