-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
#!/bin/bash | ||
#!/bin/bash -x | ||
|
||
apple_certificate_b64="$1" | ||
root_dir="$1" | ||
keychain_password="$3" | ||
apple_certificate_b64="$2" | ||
|
||
if [[ -z $apple_certificate_b64 ]] | ||
if [[ -z $root_dir || -z $keychain_password || -z $apple_certificate_b64 ]] | ||
then | ||
echo "[!] Usage: $0 <apple_certificate_b64 (base64)>" | ||
echo "[!] Usage: $0 <root_dir> <keychain_password> <apple_certificate_b64 (base64)>" | ||
exit 1 | ||
fi | ||
|
||
apple_certificate_password="" | ||
apple_certificate_decoded_path="/tmp/certificate.p12" | ||
keychain_path="$root_dir/app-signing.keychain-db" | ||
|
||
keychain_password="admin" | ||
keychain_path="$HOME/Library/Keychains/login.keychain-db" | ||
# Should we put a password? | ||
apple_certificate_password="6YXTQTG8JJ" | ||
apple_certificate="$root_dir/certificate.p12" | ||
|
||
echo "$apple_certificate_b64" | base64 --decode > "$apple_certificate_decoded_path" | ||
echo -n "$apple_certificate_b64" | base64 --decode -o "$apple_certificate" | ||
|
||
security delete-keychain "$keychain_path" | ||
|
||
# Create a temporary keychain (https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners) | ||
security create-keychain -p "$keychain_password" "$keychain_path" | ||
security set-keychain-settings -lut 21600 "$keychain_path" | ||
security unlock-keychain -p "$keychain_password" "$keychain_path" | ||
|
||
# Import certificate | ||
security import "$apple_certificate_decoded_path" -k "$keychain_path" -P "$apple_certificate_password" -T /usr/bin/security -T /usr/bin/codesign | ||
security import "$apple_certificate" -k "$keychain_path" -P "$apple_certificate_password" -A -t cert -f pkcs12 | ||
# Authorize access to certificate private key | ||
security set-key-partition-list -S apple-tool:,apple: -s -k "$keychain_password" "$keychain_path" | ||
security set-key-partition-list -S apple-tool:,apple: -k "$keychain_password" "$keychain_path" |