使用 x.509 证书的 SSL cocoa

发布于 2024-12-09 00:22:41 字数 405 浏览 0 评论 0原文

我想知道我所拥有的 x.509 证书到底在 xcode 中的什么位置。以这里为例: http://code.google。 com/p/cocoaasyncsocket/downloads/detail?name=CertTest.zip&can=1&q=

我希望能够与我正在运行的安全服务器进行通信。我似乎无法添加证书,每次添加证书时,我的 Mac 都会打开一个钥匙串窗口,询问该证书是否属于我的任何系统(除了我的项目)设置。所以我想知道我应该把它放在我的项目中的哪里以及如何使用它(我想链接中的项目会对此有所帮助)

I wanted to know where exactly in xcode do I place a x.509 certificate that I have. Taking the example from here:
http://code.google.com/p/cocoaasyncsocket/downloads/detail?name=CertTest.zip&can=1&q=

I wanted to be able to communicate with a secure server I have running. I just cant seem to add the certificate in and everytime I do, my mac opens up a keychain window asking m if the certificate belongs to any of my system (other than my project) settings. So I wanted to know where do I place it in my project and how I would use it(I guess the project at the link would help with that)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

≈。彩虹 2024-12-16 00:22:41

如果您使用 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 提供的此示例: 高级 URL 连接

If you are using NSURLConnection for connecting to your server then you should implement next methods in your delegate:

- (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.

I advice you to look through this sample by Apple: Advanced Url Connections

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文