Intermittent SSL Failures Authenticating with Server Using ASIHTTPRequest and MKNetworkKit
===

I'm working on an iOS app and I'm having intermittent SSL failures when I try to access some of the APIs on our API server.  The failures don't happen all the time, but they happen enough to be a significant problem.  When an SSL failure occurs, the error code reported is errSSLInternal (-9810).  I mostly see these problems when the app attempts to login, but I sometimes see it when accessing other APIs.

The app was written using ASIHTTPRequest and here is the code to construct the login request:

    ASIFormDataRequest *loginFormDataRequest = [[ASIFormDataRequest alloc] initWithURL:...];
    loginFormDataRequest.timeOutSeconds = 30.0f; // Included in an attempt to fix timeout problems
    loginFormDataRequest.shouldAttemptPersistentConnection = NO; // Included in an attempt to fix timeout problems
    [loginFormDataRequest addPostValue:self.username forKey:@"username"];
    [loginFormDataRequest addPostValue:self.password forKey:@"password"];
    [loginFormDataRequest addPostValue:@"1" forKey:@"applogin"];
    loginFormDataRequest.delegate = self;
    [loginFormDataRequest setDidFinishSelector:@selector(didFinishLoginFormDataRequest:)];
    [loginFormDataRequest setDidFailSelector:@selector(didFailLoginFormDataRequest:)];
    [loginFormDataRequest startAsynchronous];

Pretty straightforward.

I already updated ASIHTTPRequest in response to Apple's [Technical Note TN2287][1] and that did not help.  Neither did setting the `validatesSecureCertificate` property to `NO`. 

The encrypted connection to the server seems to check out okay.  Chrome says:

 - Your connection to [the server] is encrypted with 256-bit encryption.
 - The connection uses TLS 1.0.
 - The connection is encrypted using CAMELLIA_256_CBC, with SHA1 for message authentication and DHE_RSA as the key exchange mechanism.
 - The connection is compressed with DEFLATE.

The server is being contacted on port 442 using https.  I also tried an implementation of this login code using MKNetworkKit and I still intermittently saw an SSL error so I don't think the problem is with ASIHTTPRequest.

I'm out of ideas, so I'd be grateful for any insight any one might have.  Thanks in advance for your help!


  [1]: http://developer.apple.com/library/ios/#technotes/tn2287/_index.html "Technical Note TN2287"