Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Goodmorning I have a node.js server that must receive json calls from a node.js application that uses express to manage routers, the ios application makes calls to routers passing json values! My problem is that I can not configure the apple ATS! How can I do? below I entered both the code and the information related to info.plist


ATS Error:
ATS Default Connection
2018-05-18 08:54:14.070 nscurl[7310:57407] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
Result : FAIL
---

<pre><a href="https://imgur.com/a/zZ8QgMC">ATS Configuration </a



What I have tried:

Swift Code:
Swift
func Login(Username: String, Password: String, completion: @escaping (Int) -> ())
    {
        let semaphore = DispatchSemaphore(value: 1)
        semaphore.wait()
        let db = Database() /* https://172.16.53.247:8989 */
        let json: [String: Any] = ["Username": "" + Username, "Password": "" + Password]
        let jsonData = try? JSONSerialization.data(withJSONObject: json)
        var request = URLRequest(url: URL(string: db.GetServerURL() + "/login")!)
        request.httpMethod = "POST"
        request.httpBody = jsonData
        let task = URLSession.shared.dataTask(with: request) { data, response, error in
            guard let data = data, error == nil else {
                print(error?.localizedDescription ?? "No data")
                completion(0)
                return
            }
            let responseJSON = try? JSONSerialization.jsonObject(with: data, options: [])
            if let responseJSON = responseJSON as? [String: Any] {
                let read = responseJSON["return"]!
                let IdUser=Int(String(describing: read))!
                if (IdUser > 0) {

                    completion(IdUser)
                }
                else {
                    completion(0)
                }
            }

        }
        task.resume()
        semaphore.signal()
    }


Node.js Server:

JavaScript
const fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');

const port = 8989;

const options = {
    key: fs.readFileSync('./Config/server-key.pem'),
    cert: fs.readFileSync('./Config/server-cert.pem'),
};

var app = express();

var server = https.createServer(options, app).listen(port, function(){
  console.log("Express server listening on port " + port);
});

app.get('/', function (req, res) {
    res.writeHead(200);
    res.end("hello world\n");
});


module.exports = app;
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900