1

I am trying to setup my development environment to build my first iOS app and I am running into problems when trying to execute a REST call from within my app. The call is being made to a endpoint service (Java Springboot App) that is using a self-signed certificate (created by OpenSSL) that utilizes JWT tokens that is running on my localhost (port 8443).

Here's the specific error I am getting:
domain: "NSURLErrorDomain" - code: 18446744073709550414 0x00007fca19c9e3b0

Here's what I have done to troubleshoot:

  • I have set the "NSAppTransportSecurity" in my info.plist file
  • I disabled SSL on my endpoint service and then tried to execute the request and everything worked fine (so it seems to just be related to my SSL request)
  • Using Postman I am able to successfully retrieve data from the SSL endpoint
  • I loaded the SSL cert into a profile in the iOS simulator that I am using (it has the green check "Verified")

Here's my code:

func obtainState() {
 let postEndpoint: String = "https://localhost:8443/api/state"
 let url = NSURL(string: postEndpoint)!
 let session = NSURLSession.sharedSession()
 let request = NSMutableURLRequest(URL: url)
 request.HTTPMethod = "GET"
 request.setValue("eyJhbGciOiJIUzI1NiJ9.eyJ....", forHTTPHeaderField: "Authorization")

 session.dataTaskWithRequest(request, completionHandler: { ( data: NSData?, response: NSURLResponse?, error: NSError?) -> Void in
      guard let realResponse = response as? NSHTTPURLResponse where
      realResponse.statusCode == 200 else {
                print("Not a 200 response")
                return
      }
      if let postString = NSString(data:data!, encoding: NSUTF8StringEncoding) as? String {
            print("POST: " + postString)
      }          
    }).resume()
}

Why am getting this error and what can I do to get past it?

Thanks for any help you can provide.

  • check my answer: http://stackoverflow.com/questions/36331623/ios-9-3-an-ssl-error-has-occurred-and-a-secure-connection-to-the-server-cannot/36331872#36331872 – tush4r Apr 07 '16 at 06:39
  • 1
    Did you solved this issue. I am facing same – Dory May 30 '16 at 11:53

0 Answers0