Possible Duplicate:
Can I use NSURLCredentialStorage for HTTP Basic Authentication?
How would I accept a self-signed server certificate? Using the code below, I can only connect/authenticate after I accept the Server Cert using Safari.
- (void)secure:(NSString *)username credentials:(NSString *)login
{
NSURLCredential *userCredentials = [NSURLCredential credentialWithUser:username
password:login
persistence:
NSURLCredentialPersistenceForSession];
NSURLProtectionSpace *space = [[NSURLProtectionSpace alloc] initWithHost:LIST_URL_HTTPS
port:443
protocol:@"https"
realm:@"Restricted Area"
authenticationMethod:NSURLAuthenticationMethodHTTPBasic];
[[NSURLCredentialStorage sharedCredentialStorage] setCredential:userCredentials
forProtectionSpace:space];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:imageURL]
cachePolicy:NSURLCacheStorageNotAllowed
timeoutInterval:30];
NSURLResponse *response;
NSError *error;
NSData *returnData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
}