Last active
June 9, 2021 18:42
-
-
Save jlehikoinen/ec7bbf5d7a5696b3761df881fac4571f to your computer and use it in GitHub Desktop.
Codesign Configuration Profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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