Skip to content

Commit a91d31d

Browse files
authored
Fixes install-certificate expiry check (#151)
* Fixes indentation * Adds logging * WIP * Improves logging * Fixes error reporting * Removes debug logging * Removes debug logging * Removes OPENSSL_PKCS12_OUTPUT
1 parent 6e29426 commit a91d31d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

install-certificate/action.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,19 @@ runs:
3232
KEYCHAIN_PATH="/Users/$(whoami)/Library/Keychains/${KEYCHAIN_NAME}"
3333
KEYCHAIN_DB_PATH="${KEYCHAIN_PATH}-db"
3434
if [ -z "$CERTIFICATE_PASSWORD" ]; then
35-
echo "The password for the certificate cannot be empty."
35+
echo "::error::The password for the certificate cannot be empty."
3636
exit 1
3737
fi
3838
op read --out-file $CERTIFICATE_FILE_PATH "${{ inputs.certificate-op-reference }}"
3939
CERTIFICATE_PEM_PATH=$(mktemp)
40-
if ! openssl pkcs12 -in "$CERTIFICATE_FILE_PATH" -clcerts -nokeys -passin pass:"$CERTIFICATE_PASSWORD" -out "$CERTIFICATE_PEM_PATH" >/dev/null 2>&1; then
41-
echo "Failed to read certificate file. Check that the certificate and password are correct."
40+
OPENSSL_VERSION=$(openssl version)
41+
if echo "$OPENSSL_VERSION" | grep -qE 'OpenSSL 3'; then
42+
OPENSSL_PKCS12_FLAGS="-legacy"
43+
else
44+
OPENSSL_PKCS12_FLAGS=""
45+
fi
46+
if ! openssl pkcs12 $OPENSSL_PKCS12_FLAGS -in "$CERTIFICATE_FILE_PATH" -clcerts -nokeys -passin pass:"$CERTIFICATE_PASSWORD" -out "$CERTIFICATE_PEM_PATH" 2>&1; then
47+
echo "::error::Failed to read certificate file. Check that the certificate and password are correct."
4248
rm -f "$CERTIFICATE_PEM_PATH"
4349
exit 1
4450
fi

0 commit comments

Comments
 (0)