1

I'm trying to breath life back into a project from iOS 7.1 onto iOS 8.1. Obviously this is a NewsStand app. I need to be able to validate a certificate manually against a different host name. This all happens inside of willSendRequestForAuthenticationChallenge. On iOS 7.1 this all works fine. I even retested with an iPad still running 7.1 and it works, but on iOS 8.1 the method is never being invoked. As a result all Asset downloads fail with didFailWithError being invoked and an error of "The operation couldn’t be completed. (NSURLErrorDomain error -1202.)"

Does anyone know What might have changed in iOS 8.1 that would cause this? Are they not making the call? Did anything change with regards to inheritance on iOS 8.1 that might effect whether methods are detected and called? I did try moving all methods into the top class, but that didn't seem to help. Is it possible this is a result of using a "POST" request?

For the life of me I don't see any obvious code reason why willSendRequestForAuthenticationChallenge is not getting called on iOS 8.1 for NKAssetDownload, but is called for iOS 7.1. I never tested with iOS 8.0, so I can't say for sure it wasn't called there.

Note that the method is called for all my other URL connections I am using on iOS 8.1, so the issue seems to be specific to NKAssetDownload (or at least my invocations of NKAssetDownload).

The relevant code is:

@implementation myDownloader
{
    NKIssue         * theIssue;     // pointer to the magazine Issue object
    NSString        * theJsonReceiptArrayBase64String;
    NKAssetDownload * theAssetDownload;
    NSString        * sourceURL;
    NSString        * theFileName;
    NSString        * issueUniqueId;
    NSURLConnection * theConnection;
    NSNumber        * expectedFileSize;
}   
...

-(myDownloader *)initWithIssueAndIdAndSourceAndFinalPath:(NKIssue *)issue  uniqueId:(NSString *)uniqueId  source:(NSString *)source fileName:(NSString *)fileName fileSize:(NSNumber *) fileSize Receipt:(NSString *)receipt
{
    NSLog(@"initWithIssueAndIdAndSourceAndFinalPath");
    self = [super init];

    if (self)
    {
        theIssue        = issue;
        sourceURL       = source;
        theFileName     = fileName;
        issueUniqueId   = uniqueId;
        expectedFileSize        = fileSize;
        theJsonReceiptArrayBase64String       = receipt;
    }

    return self;
}
...

- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection
{
   /* never get here on iOS 8.1 */
    return NO;
}

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    /* never get here on iOS 8.1 */
    [self handleAuthenticationOnConnection:connection withChallenge:challenge];
}   

...   

 -(void) downloadPackage
 {
     CCommunictionMgr * communicator = [CCommunictionMgr instance];
     NSMutableURLRequest * thePackageRequest = [communicator generateJsonPostPackageRequest:sourceURL uniqueId:issueUniqueId recieptData:theJsonReceiptArrayBase64String];
     theAssetDownload = [theIssue addAssetWithRequest:thePackageRequest];
     [theAssetDownload setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:kASSET_TYPE_PACKAGE, kASSET_TYPE_DK, nil]];
     theConnection = [theAssetDownload downloadWithDelegate:self];
 }

the object "myDownloader" implements both NSURLConnectionDelegate, NSURLConnectionDownloadDelegate

headerfile

@interface myDownloader : CConnectionDelegate <NSURLConnectionDelegate, NSURLConnectionDownloadDelegate>
...

where the guts of the authentication challenge are handled inside the CConnectionDelegate object.

I am happy to include the guts of other code if needed.

John Odom
  • 1,189
  • 2
  • 20
  • 35
dboals
  • 610
  • 4
  • 10
  • Have you found a fix for this? I've also noticed that willSendRequestForAuthenticationChallenge is not being called, but is for iOS7. I'm not sure if the bug goes back to 8.0, but it's still in 8.2. I have filed a bug report with Apple, have you done the same? – Paul Reedy Mar 27 '15 at 17:43
  • Paul, I didn't file a bug report, It wasn't clear if it was intentional or not on apple's part. I can file a bug report with apple if you want me to. I posted additional questions elsewhere and never got a reply. I had to have it working, so I had to work around the problem. I had to change the target domain for the downloads so the target was the first domain in the certificate. Luckily I designed the engine to allow for an updated domain for the targets every time the app talked to the server. I did have to play some games with the servers and domains to keep the server code working. – dboals Mar 30 '15 at 14:06

0 Answers0