2011-10-10 156 views
0

我想知道xcode中的確切位置是否放置了我擁有的x.509證書。以此爲例: http://code.google.com/p/cocoaasyncsocket/downloads/detail?name=CertTest.zip&can=1&q=使用x.509證書的SSL cocoa

我希望能夠與正在運行的安全服務器進行通信。我似乎無法在每次添加證書時,我的Mac會打開一個鑰匙串窗口,詢問證書是否屬於我的任何系統(除了我的項目)設置。所以我想知道我在哪裏將它放在我的項目中,以及我將如何使用它(我想鏈接上的項目會對此有所幫助)

+0

你想給我們證書對服務器進行身份驗證? – Nekto

+0

是的,這是正確的。我似乎無法完成身份驗證。 –

回答

0

如果您使用NSURLConnection連接到服務器,則應該實現在接下來的委託方法:

- (BOOL)connection:(NSURLConnection *)conn canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace; 
// A delegate method called by the NSURLConnection when something happens with the 
// connection security-wise. We defer all of the logic for how to handle this to 
// the ChallengeHandler module (and it's very custom subclasses). 


- (void)connection:(NSURLConnection *)conn didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge 
// A delegate method called by the NSURLConnection when you accept a specific 
// authentication challenge by returning YES from -connection:canAuthenticateAgainstProtectionSpace:. 
// Again, most of the logic has been shuffled off to the ChallengeHandler module; the only 
// policy decision we make here is that, if the challenge handle doesn't get it right in 5 tries, 
// we bail out. 

我建議你通過蘋果通過這個樣本看:Advanced Url Connections

+0

啊是的。這應該工作。謝謝!不知道這個例子。 –