]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/rootStoreTool/buildSysAnchors
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / clxutils / rootStoreTool / buildSysAnchors
1 #! /bin/csh -f
2 #
3 # Build SystemRootCerts.keychain and SystemTrustSettings.plist from
4 # all the certs in a given directory. Creates these two files in
5 # $LOCAL_BUILD_DIR and copies the results into /System/Library/Keychains/.
6 #
7 if ( $#argv != 1 ) then
8 echo "Usage: buildSysAnchors cert_dir"
9 echo "A typical run, when in the rootStoreTool dir, would be:"
10 echo "buildSysAnchors ../../../security_certificates/roots"
11 exit(1)
12 endif
13
14 set BUILD_DIR=$LOCAL_BUILD_DIR
15 set ROOT_KC=SystemRootCerts.keychain
16 set ROOT_KC_PATH=$BUILD_DIR/$ROOT_KC
17 set SETTINGS_FILE=SystemTrustSettings.plist
18 set SETTINGS_FILE_PATH=$BUILD_DIR/$SETTINGS_FILE
19
20 echo Creating empty $ROOT_KC in build directory...
21 rm -f "$ROOT_KC_PATH" || exit(1)
22 security create-keychain -p password "$ROOT_KC_PATH" || exit(1)
23
24 echo Creating empty $SETTINGS_FILE in build directory....
25 rm -f "$SETTINGS_FILE_PATH" || exit(1)
26 security add-trusted-cert -o "$SETTINGS_FILE_PATH" || exit(1)
27
28 set cmd="cd $argv[1]"
29 echo $cmd
30 $cmd
31
32 set GOT_ERROR=NO
33
34 foreach root (*)
35 echo Processing $root...
36 security import "$root" -k "$ROOT_KC_PATH" -t cert || exit(1)
37 security add-trusted-cert -i "$SETTINGS_FILE_PATH" -o "$SETTINGS_FILE_PATH" "$root" || exit(1)
38 end
39
40 set DST_PATH=/System/Library/Keychains
41
42 echo Copying $ROOT_KC and $SETTINGS_FILE to $DST_PATH...
43 cp $ROOT_KC_PATH $SETTINGS_FILE_PATH $DST_PATH || exit(1)
44
45 echo "=== Done. ==="