I am trying to implement Http Digest Authentication over SSL for one of my clients. I could not find any reference related to this. Is this possible to implement?
Thanks
I am trying to implement Http Digest Authentication over SSL for one of my clients. I could not find any reference related to this. Is this possible to implement?
Thanks
After several research, I found out that, iOS does not provide any such in built support for Http authentication over SSL, expect SOCKS. But if you are desperate to implement it, create a socket and do Digest/NTLM/... handshake your self and use the same socket to create Input/Output streams. As of now, this is the only way to do it.
However, for regular Http requests such as POST/GET/... you can use NSURLConnection class as following code to authenticate the servers.
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
NSLog(@"InShiva didReceiveAuthenticationChallenge") ;
if ([challenge previousFailureCount] == 0)
{
NSLog(@"received authentication challenge");
NSURLCredential *newCredential = [NSURLCredential credentialWithUser:@"username"
password:@"password"
persistence:NSURLCredentialPersistenceForSession];
NSLog(@"credential created");
[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
NSLog(@"responded to authentication challenge");
}
else
{
NSLog(@"previous authentication failure");
}
}