Im trying to make a post request to a server with basic authentification. I tried it with the AFNetwork Library and it works! Because I want to use Restkit and already used if for a lot of things I tried to do the same with it, but it doesnt work. My code looks like that:
RKClient *client = [[RKClient alloc] initWithBaseURL:URL];
client.username = @"username";
client.password = @"password";
client.authenticationType = RKRequestAuthenticationTypeHTTPBasic;
client.disableCertificateValidation = YES;
RKRequest *request = [client post:@"mypath" params:nil delegate:self];
[request sendSynchronously];
But in the delegate
- (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error {
I always get the error:
NSLocalizedDescription=The certificate for this server is invalid. You
might be connecting to a server that is pretending to be #######
HIDDEN ####### which could put your confidential information at risk.,
_kCFNetworkCFStreamSSLErrorOriginalValue=-9813, _kCFStreamPropertySSLClientCertificateState=0, NSLocalizedRecoverySuggestion=Would you like to connect to the server
anyway?
But I set the
disableCertificationValidation
to YES
I also tried to follow the information here RestKit Pull. But that was also not helpful at all. Has anybody an idea, what can be wrong? With the AFNetwork Library the code is more or less the same, but works.
At least, I did not get my solution over RestKit. I tried everything, also added the certificates with addRootCertificates, but RestKit always get the same error.
In the end, I did it on my own.
Method addCertToKeychain:
Probably it helps someone.