Skip to content

Instantly share code, notes, and snippets.

@jlehikoinen
Last active January 17, 2024 06:47
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlehikoinen/28ec2336f82110829868931543b4ed95 to your computer and use it in GitHub Desktop.
Save jlehikoinen/28ec2336f82110829868931543b4ed95 to your computer and use it in GitHub Desktop.
Remove signature from Configuration Profile using Quick Action
# 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 <text-editor-app> at row 36 with your preferred text editor app
# Save quick action as: "Remove signature from Profile & open in <app>"
# Quick Actions live in: ~/Library/Services
# Target folder
dest_dir="$HOME/Desktop"
while read -r file; do
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}_unsigned.mobileconfig" ]]; then
/usr/bin/osascript -e "display alert \"Error: Target file already exists\""
exit 1
fi
/usr/bin/security cms -D -i "$file" | /usr/bin/xmllint --format - > "$dest_dir"/"$filename"_unsigned.mobileconfig
if [[ $? -ne 0 ]]; then
/usr/bin/osascript -e "display alert \"Failed to remove signature from Profile\""
/bin/rm "$filename"_unsigned.mobileconfig
exit 1
fi
# Change text editor here
/usr/bin/open -a <text-editor-app> "$dest_dir"/"$filename"_unsigned.mobileconfig
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment