不幸的是,今天早上我的 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
我想知道如何解决这个问题。我在这里读到了一些有用的答案,但有很多事情我仍然不明白,如果有人能帮助/解释我,我将非常感激。
将其添加到您的应用程序中Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)