Skip to content

Commit 6576929

Browse files
update run field EXPIRATION_DATE with cert type based conditional
1 parent 9de4922 commit 6576929

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

.github/workflows/check-certificates.yml

+37-20
Original file line numberDiff line numberDiff line change
@@ -124,26 +124,43 @@ jobs:
124124
CERTIFICATE_PASSWORD: ${{ secrets[matrix.certificate.password-secret] }}
125125
id: get-days-before-expiration
126126
run: |
127-
EXPIRATION_DATE="$(
128-
(
129-
openssl pkcs12 \
130-
-in "${{ env.CERTIFICATE_PATH }}" \
131-
-clcerts \
132-
-legacy \
133-
-nodes \
134-
-passin env:CERTIFICATE_PASSWORD
135-
) | (
136-
openssl x509 \
137-
-noout \
138-
-enddate
139-
) | (
140-
grep \
141-
--max-count=1 \
142-
--only-matching \
143-
--perl-regexp \
144-
'notAfter=(\K.*)'
145-
)
146-
)"
127+
if [[ ${{ matrix.certificate.type }} == "pkcs12" ]]; then
128+
EXPIRATION_DATE="$(
129+
(
130+
openssl pkcs12 \
131+
-in "${{ env.CERTIFICATE_PATH }}" \
132+
-clcerts \
133+
-legacy \
134+
-nodes \
135+
-passin env:CERTIFICATE_PASSWORD
136+
) | (
137+
openssl x509 \
138+
-noout \
139+
-enddate
140+
) | (
141+
grep \
142+
--max-count=1 \
143+
--only-matching \
144+
--perl-regexp \
145+
'notAfter=(\K.*)'
146+
)
147+
)"
148+
elif [[ ${{ matrix.certificate.type }} == "x509" ]]; then
149+
EXPIRATION_DATE="$(
150+
(
151+
openssl x509 \
152+
-in ${{ env.CERTIFICATE_PATH }} \
153+
-noout \
154+
-enddate
155+
) | (
156+
grep \
157+
--max-count=1 \
158+
--only-matching \
159+
--perl-regexp \
160+
'notAfter=(\K.*)'
161+
)
162+
)"
163+
fi
147164
148165
DAYS_BEFORE_EXPIRATION="$((($(date --utc --date="$EXPIRATION_DATE" +%s) - $(date --utc +%s)) / 60 / 60 / 24))"
149166

0 commit comments

Comments
 (0)