1 Reply
      Latest reply on Apr 8, 2016 9:48 PM by guywithmazda
      bunker Level 1 Level 1 (0 points)

        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()
            }
        
        

         

        Questions:

        • Why am getting this error and what can I do to get past it?
        • With iOS 9 can I use self-signed certificates?  Will my app be releasable to the AppStore if endusers can configure their own self-signed certs to use in my app?  
        • Is there an issue using "localhost" in local development with the Simulator?

         

        Thanks for any help you can provide.