IOS 9 发送Post请求,被ATS拦截,Bypass失效
IOS 9 Sending Post Request, Blocked by ATS, Bypass is not working
我试图绕过应用程序 T运行sport Security(ATS),它是 IOS 9 和 Xcode 7 的新功能。但是,我尝试了 info.plist绕过,我仍然有问题。我在 Xcode 6 中尝试了完全相同的代码,请求确实发送成功,因此请求应该是正确的。这可能只是新 Xcode 上的一个错误,但我想知道是否还有其他人 运行 遇到了同样的问题。我很确定我正在遵循正确的文档:https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/index.html#//apple_ref/doc/uid/TP40016240
Info.plist(未完成,只是 ATS 的一部分)
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict/>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>http://127.0.0.1:5000</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
要求:
let postData = NSMutableData(data: "username=bobbyz".dataUsingEncoding(NSUTF8StringEncoding)!)
postData.appendData("&password=form".dataUsingEncoding(NSUTF8StringEncoding)!)
let request = NSMutableURLRequest(URL: NSURL(string: "http://127.0.0.1:5000/register")!,
cachePolicy: .UseProtocolCachePolicy,
timeoutInterval: 10.0)
request.HTTPMethod = "POST"
request.HTTPBody = postData
let session = NSURLSession.sharedSession()
let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? NSHTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
这刚好发生在我身上。原来我不小心将绕过信息添加到我的单元测试 Info.plist。正如预期的那样,将其放入正确的 Info.plist 中可以解决问题。我还使用 "localhost" 而不是“127.0.0.1”,并且没有提供端口。
使用 Xcode 7 Beta 4。
我试图绕过应用程序 T运行sport Security(ATS),它是 IOS 9 和 Xcode 7 的新功能。但是,我尝试了 info.plist绕过,我仍然有问题。我在 Xcode 6 中尝试了完全相同的代码,请求确实发送成功,因此请求应该是正确的。这可能只是新 Xcode 上的一个错误,但我想知道是否还有其他人 运行 遇到了同样的问题。我很确定我正在遵循正确的文档:https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/index.html#//apple_ref/doc/uid/TP40016240
Info.plist(未完成,只是 ATS 的一部分)
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict/>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>http://127.0.0.1:5000</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
要求:
let postData = NSMutableData(data: "username=bobbyz".dataUsingEncoding(NSUTF8StringEncoding)!)
postData.appendData("&password=form".dataUsingEncoding(NSUTF8StringEncoding)!)
let request = NSMutableURLRequest(URL: NSURL(string: "http://127.0.0.1:5000/register")!,
cachePolicy: .UseProtocolCachePolicy,
timeoutInterval: 10.0)
request.HTTPMethod = "POST"
request.HTTPBody = postData
let session = NSURLSession.sharedSession()
let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? NSHTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
这刚好发生在我身上。原来我不小心将绕过信息添加到我的单元测试 Info.plist。正如预期的那样,将其放入正确的 Info.plist 中可以解决问题。我还使用 "localhost" 而不是“127.0.0.1”,并且没有提供端口。
使用 Xcode 7 Beta 4。