Ios 您能否以编程方式修改iPhone应用程序Info.plist中的NSExceptionMinimumTLSVersion?

Ios 您能否以编程方式修改iPhone应用程序Info.plist中的NSExceptionMinimumTLSVersion?,ios,objective-c,iphone,ssl,Ios,Objective C,Iphone,Ssl,我使用Charles来调试我的应用程序请求和响应,但它没有使用最新版本的TLS(iOS 9就是这么做的)。有没有一种方法可以通过编程的方式更新它,这样我就可以只对通过Xcode完成的本地构建启用它?我有一个Jenkins build服务器,它仍然需要使用新版本的TLS。这有点混乱,但您可以在运行脚本步骤中使用命令行工具PlistBuddy来完成这一点。混乱是因为它使实际的info.plist发生了更改,所以您将在git历史记录中看到它 下面的脚本将仅在调试版本上添加异常,否则将删除任何ATS异常

我使用Charles来调试我的应用程序请求和响应,但它没有使用最新版本的TLS(iOS 9就是这么做的)。有没有一种方法可以通过编程的方式更新它,这样我就可以只对通过Xcode完成的本地构建启用它?我有一个Jenkins build服务器,它仍然需要使用新版本的TLS。

这有点混乱,但您可以在运行脚本步骤中使用命令行工具PlistBuddy来完成这一点。混乱是因为它使实际的info.plist发生了更改,所以您将在git历史记录中看到它

下面的脚本将仅在调试版本上添加异常,否则将删除任何ATS异常。您可以对其进行编辑,使其更加具体,或者只需始终添加/删除毯子
nsallowsraboraryloads
标志

# Remove exception for all builds
/usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity" ${INFOPLIST_FILE} 2>/dev/null
exitCode=$? #Supresses failure if key doesn't exist

# Add exception for Debug builds
if [ "${CONFIGURATION}" == "Debug" ]
then
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity dict" ${INFOPLIST_FILE}
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains dict" ${INFOPLIST_FILE}
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:<host> dict" ${INFOPLIST_FILE}
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:<host>:NSIncludesSubdomains bool true" ${INFOPLIST_FILE}
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:<host>:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" ${INFOPLIST_FILE}
fi
#删除所有生成的异常
/usr/libexec/PlistBuddy-c“Delete:NSAppTransportSecurity”${INFOPLIST_FILE}2>/dev/null
exitCode=$#如果密钥不存在,则禁止失败
#为调试生成添加异常
如果[“${CONFIGURATION}”==“Debug”]
然后
/usr/libexec/PlistBuddy-c“Add:NSAppTransportSecurity dict”${INFOPLIST_FILE}
/usr/libexec/PlistBuddy-c“Add:NSAppTransportSecurity:NSExceptionDomains dict”${INFOPLIST_FILE}
/usr/libexec/PlistBuddy-c“Add:NSAppTransportSecurity:NSExceptionDomains:dict”${INFOPLIST_FILE}
/usr/libexec/PlistBuddy-c“Add:NSAppTransportSecurity:NSExceptionDomains::nsincludesubDomains bool true”${INFOPLIST_FILE}
/usr/libexec/PlistBuddy-c“Add:NSAppTransportSecurity:NSExceptionDomains::NSTemporaryExceptionAllowsInsecureHTTPLoads bool true”${INFOPLIST_FILE}
fi

更多信息

是否可以在运行时修改ATS设置?