@@ -4360,15 +4360,28 @@ import_apple_developer_certificate() {
43604360
43614361 security create-keychain -p " ${keychain_password} " " ${keychain} "
43624362 security default-keychain -s " ${keychain} "
4363+ # Identity validation and codesign resolve the certificate chain through the
4364+ # user search list, which a new keychain is not on. Keep the existing entries.
4365+ local search_list=() search_path
4366+ while IFS= read -r search_path; do
4367+ search_path=" $( printf ' %s' " ${search_path} " | sed -e ' s/^[[:space:]]*"//' -e ' s/"[[:space:]]*$//' ) "
4368+ [ -n " ${search_path} " ] && search_list+=(" ${search_path} " )
4369+ done < <( security list-keychains -d user)
4370+ security list-keychains -d user -s " ${keychain} " ${search_list[@]+" ${search_list[@]} " }
43634371 security unlock-keychain -p " ${keychain_password} " " ${keychain} "
43644372 security set-keychain-settings -t 3600 -u " ${keychain} "
43654373 security import " ${cert_file} " -k " ${keychain} " -P " ${APPLE_CERTIFICATE_PASSWORD} " -T /usr/bin/codesign -T /usr/bin/productbuild
4374+ # Apple's Developer ID intermediate (www.apple.com/certificateauthority/DeveloperIDG2CA.cer,
4375+ # SHA-256 F16CD3C5...43D2DF3A). GitHub's macOS images preinstall it, Blacksmith's
4376+ # macOS 27 image does not, and without it the identity is not valid.
4377+ security import " ${REPO_ROOT} /scripts/ci/apple-developer-id-g2.pem" -k " ${keychain} "
43664378 security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k " ${keychain_password} " " ${keychain} "
43674379
43684380 cert_info=" $( security find-identity -v -p codesigning " ${keychain} " | grep " Developer ID Application" | head -n 1 || true) "
43694381 if [ -z " ${cert_info} " ]; then
43704382 echo " No Developer ID Application identity found in imported Apple certificate." >&2
4371- security find-identity -v -p codesigning " ${keychain} " >&2 || true
4383+ # Without -v, invalid identities are listed with the reason they failed.
4384+ security find-identity -p codesigning " ${keychain} " >&2 || true
43724385 return 1
43734386 fi
43744387
0 commit comments