2
在iOS應用程序中,需要先簽署證書請求。當我嘗試運行一個查詢趕上這個錯誤:iOS:遇到錯誤kCFURLErrorUserCancelledAuthentication -1012?
kCFURLErrorUserCancelledAuthentication -1012.
文檔說:
kCFURLErrorUserCancelledAuthentication The connection failed because the user cancelled required authentication.
實現如下:
- (void)startConnection {
NSString *serverURL = @"host.ru/method";
MKNetworkEngine *engine = [[MKNetworkEngine alloc] initWithHostName:serverURL customHeaderFields:nil];
MKNetworkOperation *op = [engine operationWithPath:nil params:nil httpMethod:@"GET" ssl:YES];
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"client" ofType:@"p12"];
[op setShouldContinueWithInvalidCertificate:YES];
op.clientCertificate = thePath;
op.clientCertificatePassword = @"1234qwerty";
[op addCompletionHandler:^(MKNetworkOperation *operation) {
NSLog(@"[operation responseData]-->>%@", [operation responseString]);
}errorHandler:^(MKNetworkOperation *errorOp, NSError* err) {
NSLog(@"MKNetwork request error : %@", [err localizedDescription]);
}];
[engine enqueueOperation:op];
}
我在做什麼錯?
P.S.
提前收到嘗試簽名請求的證書。它在瀏覽器中單獨測試,沒關係。
android應用程序對相同的服務器請求通常是相同的方案。
你解決了這個問題嗎? –