0
    let urlString = "https://192.168.1.167:8090/Attendance/register"

    let url = NSURL(string: urlString)



    let theRequest = NSMutableURLRequest(URL: url!)

    theRequest.HTTPMethod = "POST"


    let parameters = ["firsrtName": regFirstNameTxtField.text!, "lastName": regLastNameTxtField.text!,"email": regEmailTxtField.text!,"password": regPassWordTxtField.text!,"phone": regPhoneNoTxtField.text!] as Dictionary<String, String>

    var err: NSError?

    do {
        theRequest.HTTPBody = try NSJSONSerialization.dataWithJSONObject(parameters, options: [])
    } catch let error as NSError {
        err = error
        theRequest.HTTPBody = nil
    } // pass dictionary to nsdata object and set it as request body

    theRequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
    theRequest.addValue("application/json", forHTTPHeaderField: "Accept")


    var connectRequest  = NSURLConnection(request: theRequest, delegate: self)

I am unable to post a request in swift. It worked perfectly with my older version of xcode. But now when I run it shows the following error message : UserInfo={NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.,

SErrorFailingURLKey=https://192.168.1.167:8090/Attendance/register}

Rakesh Mohan
  • 531
  • 2
  • 8
  • 21
  • 1
    Have you looked at NSAppTransportSecurity and the settings around that? Have you moved to iOS 9 as well since you started seeing these errors? The error is telling you it's to do with SSL so I could imagine it could be to do with that, especially as it looks like a self signed ssl – TommyBs Jan 11 '16 at 07:45
  • 1
    Check this:[NSURLSession/NSURLConnection HTTP load failed on iOS 9](http://stackoverflow.com/questions/30739473/nsurlsession-nsurlconnection-http-load-failed-on-ios-9) – Bista Jan 11 '16 at 07:46
  • NSAppTransportSecurity NSAllowsArbitraryLoads – Phani Sai Jan 11 '16 at 07:48
  • Yes. I have added it in info.plist. @phani sai – Rakesh Mohan Jan 11 '16 at 07:51
  • The issue still persist. – Rakesh Mohan Jan 11 '16 at 08:41
  • still shows this error : kCFStreamErrorDomainKey=1, NSUnderlyingError=0x78ead1b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61 – Rakesh Mohan Jan 11 '16 at 12:24
  • @RakeshMohan check http://stackoverflow.com/a/31694233 – Phani Sai Jan 14 '16 at 07:16

0 Answers0