NSURLErrorDomain error -1012 , try to get a https connection

1,056 views
Skip to first unread message

Alexander Buder

unread,
Nov 22, 2011, 8:25:22 AM11/22/11
to RestKit
Hy,

I get the following error. I try to connect to a server via https, I
copyed the certificate so the Xcode project.

Error:

Hit error: Error Domain=NSURLErrorDomain Code=-1012 "The operation
couldn’t be completed. (NSURLErrorDomain error -1012.)"
UserInfo=0x6ba4af0 {NSErrorFailingURLKey=https://localhost/
Immobilien/, NSErrorFailingURLStringKey=https://localhost/Immobilien/}

Thats my Code:

RKObjectManager *objectManager = [RKObjectManager
objectManagerWithBaseURL:@"https://localhost"];
objectManager.objectStore = [RKManagedObjectStore
objectStoreWithStoreFilename:@"ImmobilienRestKitSample.sqlite"];
objectManager.client.disableCertificateValidation = NO;

NSData* certData = [NSData dataWithContentsOfFile:[[NSBundle
mainBundle] pathForResource:@"localhost" ofType:@"cer"]];
if( [certData length] )
{
SecCertificateRef cert = SecCertificateCreateWithData(NULL,

(__bridge CFDataRef) certData);
if( cert != NULL )
{
[objectManager.client addRootCertificate:cert];
NSLog(@"SSL-Certificate: %@",certData);
CFRelease(cert);
}
}

Alexander Buder

unread,
Nov 24, 2011, 7:56:51 AM11/24/11
to RestKit
I found the error. the data of certificate was empty.

On Nov 22, 2:25 pm, Alexander Buder <buder.alexan...@googlemail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages