Skip to content

Instantly share code, notes, and snippets.

@xiangyu-sun
Created January 2, 2019 05:52
Show Gist options
  • Save xiangyu-sun/c82627296b95748964b3d7d57f2e3681 to your computer and use it in GitHub Desktop.
Save xiangyu-sun/c82627296b95748964b3d7d57f2e3681 to your computer and use it in GitHub Desktop.
ATS toggle
/usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity dict" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
# allow insecure connections for MOCK environment
if [ "$env" != "MOCK" ]
then
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity dict" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool NO" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoadsInWebContent bool YES" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
else
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity dict" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool NO" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoadsInWebContent bool YES" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains dict" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:localhost dict" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:localhost:NSExceptionAllowsInsecureHTTPLoads bool YES" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:localhost:NSExceptionRequiresForwardSecrecy bool YES" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:localhost:NSIncludesSubdomains bool YES" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:localhost:NSRequiresCertificateTransparency bool NO" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:localhost:NSTemporaryThirdPartyExceptionAllowsInsecureHTTPLoads bool YES" "${PROJECT_DIR}/${PROJECT_NAME}/Info.plist"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment