我的自签名证书出现以下错误
错误域= NSURLErrorDomain代码= -1200“发生SSL错误,无法建立与服务器的安全连接。
在测试我的一个演示应用程序的Web服务时
iOS 9.3
XCode 7.3
斯威夫特2.2
Alamofire 3.3.0
注意: 在假定它是重复的之前,我要求请一路阅读,即使我已经向Apple开发者论坛报告过
使用 Alamofire库
func testAlamofireGETRequest() -> Void
{
Alamofire.request(.GET, "/HelloWeb/service/greeting/john")
.responseJSON
{ response in
print("Response JSON: \(response.result.value)")
}
}
使用 NSURLSession
func testNSURLSessionRequest() -> Void {
let session = NSURLSession.sharedSession()
let urlString = "/HelloWeb/service/greeting/john"
let url = NSURL(string: urlString)
let request = NSURLRequest(URL: url!)
let dataTask = session.dataTaskWithRequest(request) { (data:NSData?, response:NSURLResponse?, error:NSError?) -> Void in
print("done, error: \(error)")
//Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made.
}
dataTask.resume()
}
我花了2天没有运气:(
已经发布了一堆问题,但对我没有任何帮助
发布Alamofire git问题
我的 Info.pist 文件以这种方式更新了ATS设置
NSAppTransportSecurity
NSExceptionDomains
NSExceptionRequiresForwardSecrecy
NSExceptionAllowsInsecureHTTPLoads
NSIncludesSubdomains
NSTemporaryExceptionAllowsInsecureHTTPLoads
同时,我能够得到回应
谁能建议我,为什么我在付出巨大努力后仍无法正常工作?