Skip to content

Instantly share code, notes, and snippets.

@jlehikoinen
Last active June 9, 2021 18:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlehikoinen/ec7bbf5d7a5696b3761df881fac4571f to your computer and use it in GitHub Desktop.
Save jlehikoinen/ec7bbf5d7a5696b3761df881fac4571f to your computer and use it in GitHub Desktop.
Codesign Configuration Profile
# Automator > Quick Action
# Workflow receives current "files or folders" in "Finder"
# Add "Run Shell Script" action
# Copy script below to "Run Shell Script" window
# Replace <codesigning certificate> at row 28 with your preferred certificate
# Save quick action as: "Sign Configuration Profile"
# Quick Actions live in: ~/Library/Services
# Receives files and folders
while read -r file; do
dest_dir="${file%/*}"
filename="${file##*/}"
filename="${filename%.*}"
ext="${file##*.}"
if [[ $ext != "mobileconfig" ]]; then
/usr/bin/osascript -e "display alert \"Error: Only .mobileconfig files supported\""
exit 1
fi
if [[ -f "$dest_dir"/"${filename}_signed.mobileconfig" ]]; then
/usr/bin/osascript -e "display alert \"Error: Target file already exists\""
exit 1
fi
# Sign profile using certificate found in keychain
/usr/bin/security cms -S -N "<codesigning certificate>" -i "$file" -o "$dest_dir"/"${filename}_signed.mobileconfig"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment