rikidev Ответов: 0

Конфигурация ATS включена node.js с помощью express.js


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:
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



Что я уже пробовал:

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 Сервер:

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;

0 Ответов