Skip to content

Commit 6db0fb7

Browse files
katipallyCopilot
andcommitted
fix(ci): use || RC=$? to prevent set -e suppressing openssl diagnostics
With set -euo pipefail, 'OPENSSL_OUT="$(cmd)"' exits the script immediately when cmd fails — before the error echo runs. Use the '|| RC=$?' pattern so set -e is not triggered and the error output is actually printed to the log. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent eccc1dd commit 6db0fb7

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

.github/workflows/ios-testflight.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,25 @@ jobs:
148148
149149
# Normalize via openssl so CryptoKit gets a canonical PEM structure
150150
# (correct line width, no stray bytes, clean header/footer).
151-
# Show the error if it fails — the error message is not secret data.
152-
OPENSSL_OUT="$(openssl pkey -in "$RAW_FILE" -out "$KEY_FILE" 2>&1)"
153-
OPENSSL_RC=$?
151+
# Use || RC=$? to prevent set -e from triggering — we handle the failure.
152+
OPENSSL_RC=0
153+
OPENSSL_OUT="$(openssl pkey -in "$RAW_FILE" -out "$KEY_FILE" 2>&1)" || OPENSSL_RC=$?
154154
if [ $OPENSSL_RC -eq 0 ]; then
155155
echo "Key normalized via openssl pkey"
156156
else
157157
echo "openssl pkey failed (rc=${OPENSSL_RC}): ${OPENSSL_OUT}"
158-
# Try pkcs8 sub-command as fallback (handles PKCS#8 keys explicitly)
159-
OPENSSL_OUT2="$(openssl pkcs8 -nocrypt -in "$RAW_FILE" -out "$KEY_FILE" 2>&1)"
160-
if [ $? -eq 0 ]; then
158+
# Try pkcs8 sub-command as fallback
159+
OPENSSL_RC2=0
160+
OPENSSL_OUT2="$(openssl pkcs8 -nocrypt -in "$RAW_FILE" -out "$KEY_FILE" 2>&1)" || OPENSSL_RC2=$?
161+
if [ $OPENSSL_RC2 -eq 0 ]; then
161162
echo "Key normalized via openssl pkcs8"
162163
else
163-
echo "openssl pkcs8 also failed: ${OPENSSL_OUT2}"
164+
echo "openssl pkcs8 also failed (rc=${OPENSSL_RC2}): ${OPENSSL_OUT2}"
164165
cp "$RAW_FILE" "$KEY_FILE"
165166
echo "Warning: using cleaned raw key without openssl normalization"
166167
fi
167168
fi
168-
# Print first line (PEM header) for diagnostics not secret content
169+
# Print PEM header for diagnostics (not secret content)
169170
HEADER=$(head -1 "$RAW_FILE")
170171
echo "PEM header line: '${HEADER}'"
171172
rm -f "$RAW_FILE"

0 commit comments

Comments
 (0)