简体   繁体   中英

HowTo: iPhone Web Service call to WCF Service with Certificate Authentication

We are a .Net shop currently developing a iPhone app that requires the app to call a WCF web service. Our WCF Services are secured with a x509 certificate for authentication purposes.

I have been searching the internet for an example on how to do the following:

  1. Deploy a certificate with an iPhone app.
  2. Use that certificate in a web service call to a WCF Service.

Any insight on how this might be accomplished would be greatly appreciated.

One could use the NSURLConnection API in asynchronous mode. You'll need to implement an object with the NSURLConnectionDelegate protocol (http://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSURLConnectionDelegate) .

The delegate will get a call on the method connection:didReceiveAuthenticationChallenge: when the server challenges for a certificate.

See the Apple guide for the URL loading system (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/AuthenticationChallenges.html#//apple_ref/doc/uid/TP40009507-SW1)

For loading an SSL cert from the bundle see this StackOverflow answer :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM