Created
January 23, 2022 19:54
-
-
Save backslash-f/66c9bdd40e7dc56d7d376299df3dc7c9 to your computer and use it in GitHub Desktop.
Revisions
-
backslash-f revised this gist
Jan 23, 2022 . No changes.There are no files selected for viewing
-
backslash-f created this gist
Jan 23, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ // "Charles Enabler" // https://stackoverflow.com/a/57253011/584548 public class NetworkEnabler: NSObject, URLSessionDelegate { public func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!)) } } // Then, when creating a URLSession instance: let urlSession = URLSession(configuration: .default, delegate: NetworkEnabler(), delegateQueue: nil) // Create a request and finally... let (data, response) = try await urlSession.data(for: request) // Profit 💰