-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcert
executable file
·63 lines (52 loc) · 1.67 KB
/
cert
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
# The name of the keychain to create for iOS code signing.
KEYCHAIN=ck-ios-build.keychain
import_certs ()
{
local password=cibuild
if security unlock-keychain -p "$password" "$KEYCHAIN" >/dev/null 2>&1
then
echo "warnning: $KEYCHAIN already exist, force removed"
security delete-keychain "$KEYCHAIN"
fi
echo "*** Setting up code signing..."
# Create a temporary keychain for code signing.
security create-keychain -p "$password" "$KEYCHAIN"
security default-keychain -s "$KEYCHAIN"
security unlock-keychain -p "$password" "$KEYCHAIN"
security set-keychain-settings -t 3600 -l "$KEYCHAIN"
# Download the certificate for the Apple Worldwide Developer Relations
# Certificate Authority.
local certpath="$SCRIPT_DIR/apple_wwdr.cer"
curl 'https://developer.apple.com/certificationauthority/AppleWWDRCA.cer' > "$certpath"
security import "$certpath" -k "$KEYCHAIN" -T /usr/bin/codesign
[ -z "$KEY_PASSWORD" ] && echo "warning: KEY_PASSOWRD is not defined"
# Import certificates.
for c in $SCRIPT_DIR/certificates/*.p12;
do
[ "$c" = "$SCRIPT_DIR/certificates/*.p12" ] && break
security import "$c" -k "$KEYCHAIN" -P "$KEY_PASSWORD" -T /usr/bin/codesign
done
}
delete_keychain ()
{
security delete-keychain "$KEYCHAIN"
}
main () {
if [ -z "$SCRIPT_DIR" ];
then
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
fi
case "$1" in
--import)
import_certs
;;
--remove)
delete_keychain
;;
*)
echo "Usage: cert <--import|--remove>"
;;
esac
}
main "$@"