I am trying to send some data that the user will select to a mysql database on a LAMP server that is on a different network. Recently I downloaded a server on my own machine and everything was fine. The action in the app sent to the php file which was in the server and then of course the php handled sending this to the mysql database. Recently I was given access to a server which we will need to use. Now when I try to do the same thing I get an error saying the certificate for this server is invalid. I know that previously I was dealing with http and now it will need to be https, but I am not clear on how I should change this to make it work properly. I see a lot of different responses here on how to do this, but they are often countered with comments such as "This is a workaround" or "the app could be rejected" and so forth.
Here is my current function:
func sendToServer(firstEntry: String, secondEntry: String, serverAddr: String){
let uid = firstEntry
let gender = secondEntry
let request = NSMutableURLRequest(url: NSURL(string: serverAddr)! as URL)
request.httpMethod = "POST"
let postString = "UID=\(uid)&Gender=\(gender)"
request.httpBody = postString.data(using: String.Encoding.utf8)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
if error != nil {
print("error=\(error)")
return
}
print("response = \(response)")
let responseString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
print("responseString = \(responseString)")
}
task.resume()
}
I read things such as not using shared here to get it to work, but I am still not quite clear on this. All I want to do is send this data to a php located on the server. The data itself is not sensitive, it is just simply gender and yes or no answers that get sent to a database. However, I would need this to be secure enough where there are no attacks that effect the user experience and where it won't be rejected for this reason. Any help here would be much appreciated. Thanks