无法将iOS App与AWS EC2服务器连接

时间:2019-05-13 02:34:36

标签: swift xcode https

我正在将iOS应用程序的注册码测试到AWS EC2上托管的服务器(tomcat,apache)上。我不断收到这样的错误:

  

TIC SSL信任错误[1:0x283bc6280]:3:0

     

NSURLSession / NSURLConnection HTTP加载失败   (kCFStreamErrorDomainSSL,-9813)

     

任务<2F787366-D258-488D-AD2C-2FE696D08BF2>。<1> HTTP加载失败   (错误代码:-1202 [3:-9813])。

我根据以下建议搜索并更改了 info.plist

// Here are my sample codes
// Send HTTP Request to Register user
let myUrl = URL(string: "https://ec2xxx.compute.amazonaws.com:8080/MyAPISever/api.json")
var request = URLRequest(url:myUrl!)

request.httpMethod = "POST"// Compose a query string

let postString = "username=\(userName)&password=\(userPassword)&first_name=\(firstName)&last_name=\(lastName)&email=\(userEmail)"

request.httpBody = postString.data(using: String.Encoding.utf8);

let task = URLSession.shared.dataTask(with: request) { (data: Data?, response: URLResponse?, error: Error?) in

 // parse response....

 task.resume()

问题仍然存在。我正在使用Swift 4.0和Xcode 10.2。这是我的info.plist新增内容:

Allow Arbitary Loads

Exception Domains : amazonaws.com

IncludeSubdomains : true

NSExceptionAllowsInsecureHTTPLoads : true

NSExceptionRequiresForwardSecrecy : false

NSExceptionMinimumTLSVersion : TLSv1.2

NSRequiresCertificateTransparency : false

0 个答案:

没有答案