NSURLSessionDownloadTask switching from http to https

I have AFHTTPSessionManagercreated one NSURLSessionDownloadTask, used to download video in an application, which sometimes when initialized with the http: 80 URL converts it to https: 443. This happens before the connection is attempted (I added a custom HTTP protocol class to the session NSURLSessionConfigurationso that register when connected).

At the time of the request, the request for

-(NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response 

delegate the method of my class CustomHTTPProtocolDelegate, the request has been changed to https.

Application transport security is disabled ( NSAllowsArbitraryLoads=true), and this behavior seems to be associated with a specific server only with an http server (another server with an http server has no problems, and the connection is made as http on port 80).

Any idea what could happen? Anything else I could do for debugging?

Here's how the boot task is created (including the custom debug protocol class):

    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    NSURLSessionConfiguration* config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
    config.protocolClasses = @[[CustomHTTPProtocol class]];
    AFHTTPSessionManager *session = [[AFHTTPSessionManager manager] initWithSessionConfiguration:config];

    self.downloadTask = [session downloadTaskWithRequest:request  progress:&progress destination:^NSURL *(NSURL *targetPath, NSURLResponse *response){

...

[UPDATE] This issue causes us a number of headaches, so to help ease troubleshooting, I created a small test project to help solve the problem. My simple project has two functions: uploads a URL to a UIWebView and uploads a file using NSURLSessionDownloadTask. The URLs of these actions follow this pattern: WebView URL: https://console.company.com/home.html Download URL: http://data.company.com/file.txt And these host names allow different IP -addresses (different servers).

-, , - URL-, URL- HTTPS, . , iOS TLS HTTPS, -, *.company.com. , , , *.company.com TLS.

+4
1

. HSTS . NSURLSession , HTTP- HTTPS .

0

Source: https://habr.com/ru/post/1680424/


All Articles