3636 - identifier : macOS signing certificate # Text used to identify certificate in notifications.
3737 certificate-secret : INSTALLER_CERT_MAC_P12 # Name of the secret that contains the certificate.
3838 password-secret : INSTALLER_CERT_MAC_PASSWORD # Name of the secret that contains the certificate password.
39+ type : pkcs12
3940 - identifier : Windows signing certificate
40- certificate-secret : INSTALLER_CERT_WINDOWS_PFX
41- password-secret : INSTALLER_CERT_WINDOWS_PASSWORD
41+ certificate-secret : INSTALLER_CERT_WINDOWS_CER
42+ # The password for the Windows certificate is not needed, because its not a container, but a single certificate.
43+ type : x509
4244
4345 steps :
4446 - name : Set certificate path environment variable
5759 CERTIFICATE_PASSWORD : ${{ secrets[matrix.certificate.password-secret] }}
5860 run : |
5961 (
60- openssl pkcs12 \
62+ openssl ${{ matrix.certificate.type }} \
6163 -in "${{ env.CERTIFICATE_PATH }}" \
6264 -legacy \
6365 -noout \
@@ -84,26 +86,43 @@ jobs:
8486 CERTIFICATE_PASSWORD : ${{ secrets[matrix.certificate.password-secret] }}
8587 id : get-days-before-expiration
8688 run : |
87- EXPIRATION_DATE="$(
88- (
89- openssl pkcs12 \
90- -in "${{ env.CERTIFICATE_PATH }}" \
91- -clcerts \
92- -legacy \
93- -nodes \
94- -passin env:CERTIFICATE_PASSWORD
95- ) | (
96- openssl x509 \
97- -noout \
98- -enddate
99- ) | (
100- grep \
101- --max-count=1 \
102- --only-matching \
103- --perl-regexp \
104- 'notAfter=(\K.*)'
105- )
106- )"
89+ if [[ ${{ matrix.certificate.type }} == "pkcs12" ]]; then
90+ EXPIRATION_DATE="$(
91+ (
92+ openssl pkcs12 \
93+ -in "${{ env.CERTIFICATE_PATH }}" \
94+ -clcerts \
95+ -legacy \
96+ -nodes \
97+ -passin env:CERTIFICATE_PASSWORD
98+ ) | (
99+ openssl x509 \
100+ -noout \
101+ -enddate
102+ ) | (
103+ grep \
104+ --max-count=1 \
105+ --only-matching \
106+ --perl-regexp \
107+ 'notAfter=(\K.*)'
108+ )
109+ )"
110+ elif [[ ${{ matrix.certificate.type }} == "x509" ]]; then
111+ EXPIRATION_DATE="$(
112+ (
113+ openssl x509 \
114+ -in "${{ env.CERTIFICATE_PATH }}" \
115+ -noout \
116+ -enddate
117+ ) | (
118+ grep \
119+ --max-count=1 \
120+ --only-matching \
121+ --perl-regexp \
122+ 'notAfter=(\K.*)'
123+ )
124+ )"
125+ fi
107126
108127 DAYS_BEFORE_EXPIRATION="$((($(date --utc --date="$EXPIRATION_DATE" +%s) - $(date --utc +%s)) / 60 / 60 / 24))"
109128
0 commit comments