Unfortunately this morning my XCode updated to version 7 and the iOS app I was developing with http now wants https. So, following many tutorials, I configured my MAMP server in order to use https/ssl creating a dummy certificate. Now in my iOS app URLs are like the following:
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"
and they work fine if I try to access them in my browser. I was used to access the database and php files with NSURLSession.sharedSession().dataTaskWithRequest() which now raises the error in title. For example, here's the line where error is raised:
if let responseJSON: [[String: String]] = (try? NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions())) as? [[String: String]] {
...
}
and this is the complete error message:
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
I would like to know how to fix this. I've read some useful answers here but there are many things I still don't understand and if anyone would help/explain me I'd be very grateful.
Add this to your app's Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>