TIC TCP Conn失败[1:0x1c0164080]:12:8 Err(-65554)和HTTP加载失败(错误代码:-1003 [12:8])

时间:2018-04-05 14:12:06

标签: ios swift ssl-certificate nsmutableurlrequest

我试图将dataTask发送到拥有ssl证书的服务器,但我收到了这样的错误:

TIC TCP Conn Failed [2:0x1c0165340]: 12:8 Err(-65554)
HTTP load failed (error code: -1003 [12:8]) 

我正在使用https的网址,我认为我需要做其他事情以允许https连接。

这是我的代码:

func doTask( completion: @escaping (_ dictionary: NSDictionary) -> Void)->Void{
    self.start()
    let URL = NSURL(string: Constants.baseUrl+self.url)!
    let request = NSMutableURLRequest(url: URL as URL)
    request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
    request.httpMethod = "POST"
    let jsonData = try? JSONSerialization.data(withJSONObject: self.data)
    request.httpBody = jsonData
    let task = URLSession.shared.dataTask(with: request as URLRequest){ data,response,error in
        let cleanJson = ServerResponseValidator().isJson(data: data);
        if(data != nil){
            let outputStr  = String(data: data!, encoding: String.Encoding.utf8) as String!
            print(outputStr!)
            completion(cleanJson)
            self.stop()
            if error != nil{
                print(error?.localizedDescription ?? "")
                return
            }
        }else{
            completion(NSDictionary())
        }


    }
    task.resume()

}

的Info.plist:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>preguntapp.mx</key>
        <dict>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

0 个答案:

没有答案