很不幸,今天早上我的XCode升级到了7版,并且我正在使用http开发的iOS应用程序要求使用https。因此,根据许多教程,我配置了我的MAMP服务器以使用https/ssl创建虚拟证书。现在我的iOS应用程序中的URL如下:
static var webServerLoginURL = "https://localhost:443/excogitoweb/mobile/loginM.php"
static var webServerGetUserTasks = "https://localhost:443/excogitoweb/mobile/handleTasks.php"
static var webServerGetUsers = "https://localhost:443/excogitoweb/mobile/handleUsers.php"
static var webServerGetProjects = "https://localhost:443/excogitoweb/mobile/handleProjects.php"
如果我尝试在浏览器中访问它们,它们就能正常工作。 我过去使用 NSURLSession.sharedSession().dataTaskWithRequest() 访问数据库和 php 文件,但现在会出现标题中的错误。例如,以下是引发错误的行:
if let responseJSON: [[String: String]] = (try? NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions())) as? [[String: String]] {
...
}
以下是完整的错误信息:
2015-09-21 16:41:48.354 ExcogitoWeb[75200:476213] CFNetwork SSLHandshake failed (-9824)
2015-09-21 16:41:48.355 ExcogitoWeb[75200:476213] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9824)
fatal error: unexpectedly found nil while unwrapping an Optional value
我想知道如何解决这个问题。我已经在这里阅读了一些有用的答案,但仍有很多事情我不理解,如果有人能帮助/解释一下,我将非常感激。