I'm trying to develop a simple, one file proof of concept. The code is as follows:
int main(int argc, const char *argv[])
{
NSString* requestString = @"https://www.example.com";
NSURL* requestUrl = [NSURL URLWithString:requestString];
NSURLRequest* request = [NSURLRequest requestWithURL:requestUrl
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:10.0f];
NSURLConnection* connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
return 0;
}
The request to example.com
over HTTPS uses a private CA, so I need to trust that CA. To trust that CA, I need to add some code to NSURLConnectionDelegate
's -connection:didReceiveAuthenticationChallenge:
The problem is I need the NSURLConnection
's delegate for the callback, and the only way I know how to do it is with another separate object.
Is it possible to flatten the delegate into a static function so I can keep all code in a single file?