2012-02-14 178 views
0

我創建了一個使用https託管的WCF Web服務,我需要使用iPhone應用程序訪問此服務。
服務工作正常我可以使用瀏覽器檢索數據。在這種情況下,我需要預先批准證書(「該服務器的證書無效」)
但是在iPhone應用程序中,我無法使其工作。
我迄今所做的是:驗證iOS中的SSL證書

 - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{ 
[[challenge sender]continueWithoutCredentialForAuthenticationChallenge:challenge]; 

}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{ 
NSLog(@"%@",error.description); } 

與錯誤的連接返回(說一個瀏覽器說什麼)
的請求應該返回一個字符串或者很簡單的東西。

我該怎麼做呢?順便說一句,我使用iOS5.0 感謝

回答

2

發現了它,只需要一個多行添加到connection willSendRequestForAuthenticationChallenge方法

[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];