前幾天我發現了ASIHTTPRequest,現在我被阻塞了。 我想通過https地址驗證我的自我(https://user:[email protected]/0.1/userCom/?apikey=12432)ASIHTTPRequest身份驗證
我試試這個代碼:
NSURL *url = [NSURL URLWithString:@"https://api.domain.com/0.1/userCom/?apikey=12432"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request setUsername:@"myUserName"];
[request setPassword:@"myPassword"];
[request startAsynchronous];
而且我已經實現了委託方法
-(void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
NSLog(@"Failed %@ with code %d and with userInfo %@",[error domain],[error code],[error userInfo]);
}
-(void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"Finished : %@",[request responseString]);
}
當我啓動我的應用程序直接調用requestFailed方法,並且我收到以下消息:
Failed ASIHTTPRequestErrorDomain with code 1 and with userInfo {
NSLocalizedDescription = "A connection failure occurred: SSL problem (possibly a bad/expired/self-signed certificate)";
NSUnderlyingError = "Error Domain=NSOSStatusErrorDomain Code=-9807 \"The operation couldn\U2019t be completed. (OSStatus error -9807.)\" UserInfo=0x680fbf0 {}";
有想法解決這個問題嗎? 非常感謝!
i)這不是我的服務器,所以我會檢查這與我的客戶端:) 如果我嘗試https:// user:[email protected]/0.1/userCom/?apikey = 12432對我Safari Mac沒有問題。 ii)運作良好! 感謝您的幫助。如果你有任何其他的東西要添加,請寫下:) – Pierre 2010-08-07 11:50:00
這可能是你的Mac有一些證書頒發機構提出的iphone沒有,並且缺少證書頒發機構可能導致這種錯誤。如果你在設備上的safari上出現類似的錯誤,那麼這就是問題 - 如果設備上的safari工作正常,那麼它可能是某種asihttprequest錯誤。 – JosephH 2010-08-07 12:49:37
在大多數情況下禁用證書檢查幫助 – knuku 2010-11-23 15:01:25