【发布时间】:2015-12-18 07:50:49
【问题描述】:
不幸的是,今天早上我的 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
我想知道如何解决这个问题。我在这里阅读了一些有用的答案,但还有很多我不明白的地方,如果有人能帮助/解释我,我将不胜感激。
【问题讨论】: