Open KaneCheshire opened 4 years ago
@KaneCheshire this is the bash script Charles proxy uses
#/bin/bash
#
# Installs the Charles Root certificate into the iOS Simulators for the current user.
SHA1=$1
SUBJ=$2
TSET=$3
DATA=$4
install() {
if [ -f "$SQLITEDBPATH" ]; then
cp -n "$SQLITEDBPATH" "$SQLITEDBPATH.charlesbackup"
sqlite3 "$SQLITEDBPATH" <<EOF
INSERT INTO "tsettings" VALUES(X'$SHA1',X'$SUBJ',X'$TSET',X'$DATA');
EOF
fi
}
for SQLITEDBPATH in ~/Library/Application\ Support/iPhone\ Simulator/3.*/Library/Keychains/TrustStore.sqlite3
do install
done
for SQLITEDBPATH in ~/Library/Application\ Support/iPhone\ Simulator/4.*/Library/Keychains/TrustStore.sqlite3
do install
done
for SQLITEDBPATH in ~/Library/Developer/CoreSimulator/Devices/*/data/Library/Keychains/TrustStore.sqlite3
do install
done
SQLITEDBPATH=~/Library/Application\ Support/iPhone\ Simulator/User/Library/Keychains/TrustStore.sqlite3
install
echo "The Charles Root Certificate has been installed for the iPhone Simulator"
Xcode 11.4 now supports adding certificates, so this could be a solution, right?
simctl supports a keychain subcommand. This command can add certificates to the trusted root store or the keychain. It can also reset the keychain, deleting all saved items. For example, to install “my-selfsigned.cer” to the trusted root store:
xcrun simctl keychain <device> add-root-cert my-selfsigned.cer
Adding a certificate to the trusted root store causes TLS/SSL connections to trust the certificate. (56213319)
Oh nice, I'll try and find some time to revisit this! Sounds very promising.
So this is more of a challenge than I anticipated because it's difficult to get the CA cert into the simulator.