我们是一家 .Net 商店,目前正在开发一款 iPhone 应用程序,该应用程序需要调用 WCF Web 服务。我们的 WCF 服务通过用于身份验证目的的 x509 证书进行保护。
我一直在互联网上搜索有关如何执行以下操作的示例:
- 使用 iPhone 应用部署证书。
- 在对 WCF 服务的 Web 服务调用中使用该证书。
任何有关如何实现这一目标的见解将不胜感激。
最佳答案
可以在异步模式下使用 NSURLConnection API。您需要使用 NSURLConnectionDelegate 协议(protocol)实现一个对象(http://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSURLConnectionDelegate)
。
当服务器对证书提出质询时,委托(delegate)将调用connection:didReceiveAuthenticationChallenge:
方法。
请参阅有关 URL 加载系统的 Apple 指南(http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/AuthenticationChallenges.html#//apple_ref/doc/uid/TP40009507-SW1)
要从 bundle 中加载 SSL 证书,请参阅此 StackOverflow answer :
关于iphone - 如何: iPhone Web Service call to WCF Service with Certificate Authentication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2232351/