我想知道xcode中的确切位置我是否放置了x.509证书。以这里为例: http://code.google.com/p/cocoaasyncsocket/downloads/detail?name=CertTest.zip&can=1&q=
我希望能够与我运行的安全服务器进行通信。我似乎无法添加证书,每次我都这样做,我的mac打开一个钥匙串窗口,询问m证书是否属于我的任何系统(我的项目除外)设置。所以我想知道我将它放在我的项目中以及如何使用它(我想链接上的项目会对此有所帮助)
答案 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.
我建议您通过Apple查看此示例:Advanced Url Connections