Cómo agregar un proxy HTTPS a NSURLSession en SWIFT 3
He utilizado el siguiente código para conectarme al servidor proxy y funciona muy bien solo para solicitudes HTTP pero no para HTTPS. En iOS 9.0,kCFStreamPropertyHTTPSProxyHost ykCFStreamPropertyHTTPSProxyPort son depreciados
let myPortInt = 12345;
let myProxyUrlString = "myProxyURL";
let sessionConfiguration = NSURLSessionConfiguration.defaultSessionConfiguration();
sessionConfiguration.connectionProxyDictionary = [
kCFNetworkProxiesHTTPEnable: true,
kCFNetworkProxiesHTTPPort: myPortInt,
kCFNetworkProxiesHTTPProxy: myProxyUrlString,
]
let url = NSURL(string: endPointUrl)
let postRequest = NSMutableURLRequest(URL: url!, cachePolicy: NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 10.0)
let jsonString = bodyString
postRequest.HTTPBody = jsonString
postRequest.HTTPMethod = "POST"
postRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
let session = NSURLSession(configuration: sessionConfiguration)
let task = session.dataTaskWithRequest(postRequest){}