title: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “domain”
body: <p>I am trying to fetch JSON from a URL but cannot do so because an error is occuring and therefore response and data are nil.</p>
  
  <p>My code for getting data from URL</p>
  
  <pre><code> loadData(urlString: String, completion : @escaping (Player,Player) -&gt; Void) -&gt; Void {
      let config = URLSessionConfiguration.default
  
      let session = URLSession(configuration: config)
  
      let url = URL(string: urlString)
      let task = session.dataTask(with: url!){data,response,error in
          if error != nil{
              print("problem in loading data");
              print(error.debugDescription);
          } else{
              let players = self.parseJson(data: data as NSData?)
  
              let priority = DispatchQueue.global(qos: .userInitiated)
              priority.async {
                  DispatchQueue.main.async {
                      completion(players.0, players.1);
                  }
              }
          }
      }
      task.resume();
  </code></pre>
  
  <p>And the Debug description of the error is as follows with the details of App Transport Security in info.plist -
  <a href="https://i.stack.imgur.com/dKxyJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dKxyJ.png" alt="Image showing info.plist and error.debugDescription"></a> </p>
  
  <p>And the image of code I a using for getting the data from JSON URL.
  <a href="https://i.stack.imgur.com/2kVZT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2kVZT.png" alt="enter image description here"></a></p>