Skip to content

Commit 541bcdd

Browse files
committed
fix(sign-windows): surface keytool errors instead of silencing them
The keytool invocation that discovers the PKCS#11 key alias had `2>/dev/null` on its stderr. Combined with `set -o pipefail`, any keytool failure exited the script silently with no diagnostic output — the v0.15.0 release attempt failed this way after `Get Certificates` and we had no error message to debug from. Capture full keytool output to a log file, dump it, and fail with explicit messages for both keytool errors and missing PrivateKeyEntry.
1 parent e1d7177 commit 541bcdd

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

scripts/windows-sign.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,25 @@ library = $P11_CLIENT
236236
slotListIndex = 0
237237
CFGEOF
238238

239-
# Discover key alias
240-
KEY_ALIAS=$(keytool -list -keystore NONE -storetype PKCS11 \
239+
# Discover key alias. Capture full keytool output so failures surface in CI
240+
# logs — previously this had `2>/dev/null` and `set -o pipefail` killed the
241+
# script silently when keytool errored.
242+
KEYTOOL_LOG="/tmp/keytool.log"
243+
echo "==> Running keytool to discover key alias..."
244+
if ! keytool -list -keystore NONE -storetype PKCS11 \
241245
-providerClass sun.security.pkcs11.SunPKCS11 \
242-
-providerArg "$PKCS11_CFG" -storepass "" 2>/dev/null \
243-
| grep "PrivateKeyEntry" | head -1 | cut -d, -f1 | tr -d ' ')
246+
-providerArg "$PKCS11_CFG" -storepass "" > "$KEYTOOL_LOG" 2>&1; then
247+
echo "==> keytool failed (exit $?). Output:"
248+
cat "$KEYTOOL_LOG"
249+
exit 1
250+
fi
251+
echo "==> keytool output:"
252+
cat "$KEYTOOL_LOG"
253+
KEY_ALIAS=$(grep "PrivateKeyEntry" "$KEYTOOL_LOG" | head -1 | cut -d, -f1 | tr -d ' ')
254+
if [[ -z "$KEY_ALIAS" ]]; then
255+
echo "==> Error: no PrivateKeyEntry found in keytool output"
256+
exit 1
257+
fi
244258
echo "==> Key alias: $KEY_ALIAS"
245259

246260
for f in "$@"; do

0 commit comments

Comments
 (0)