iPhone web service calls to WCF Service with Certificate Authentication

前端 未结 5 729
盖世英雄少女心
盖世英雄少女心 2020-12-05 01:06

We are a .Net shop that has standardized on WCF Services. We are in the processs of developing an iPhone application that needs to make secure web services calls to obtain d

相关标签:
5条回答
  • 2020-12-05 01:37

    Generally, if you want to install certificates on the iPhone, there are two options I have found (both of them from here):

    • Email the certificate to the recipient. If it is a valid certificate and the headers in the email are in order, then it will allow the recipient of the email to install the certificate. The problem here of course is a man-in-the-middle attack.

    • Use the iPhone enterpirse configuration utlity.

    That should get you part of the way there (installing the certificate locally). I should note that in general, you don't want to install one certifiate for the entire application, but have separate certificates for your users. As a general practice, authenticating the application is a very bad thing, whereas you should be authenticating the user.

    However, if you are authenticating the user already, then this shouldn't be an issue, as using basic authentication over HTTPS would work just as well (and easier to code).

    0 讨论(0)
  • 2020-12-05 01:38

    An iPhone should be able to access a Certificate-secured WCF application. If you make your WCF service a RP of Azure ACS it should work using OAuth among other methods.

    Take a look at the samples here for more: http://acs.codeplex.com/

    0 讨论(0)
  • 2020-12-05 01:56

    For starters, I'd say if you are really serious about security please dedicate the proper time and resources to it and treat it like a first class citizen in your feature list. Don't just "turn on SSL" and pretend things are secure. I'm not suggesting you are doing this or not doing this, but I just feel like I have to say it before proceeding.

    That said, you probably already know that WS-* is all built on top of http requests, and any time you are doing loads of http requests, you'll probably find ASIHTTPRequest very helpful on the iPhone. However, that will not get you 100% of the way there.

    From the iPhone's perspective you have:

    1. The URL loading system, which is a high level API for dealing with network resources of any kind
    2. The CFNetwork C API which is lower-level and allows you a great deal more control of encrypting streams and network traffic any way you see fit
    3. The Certificate, Key, and Trust Services that do the heavy lifting, and more specifically the X509 trust policies

    On Macs you get to use Secure Transport, but as far as I know they haven't ported that to the device so I wouldn't get too distracted reading up on that unless you are planning on bringing this to the desktop or are just in the mood to learn everything :)

    If you are doing any security with WCF, the first thing you probably realized is that there are many options available to you, but it all boils down to this short list:

    1. Transport layer security (https) with clear text messages (xml/json/...)
    2. Message layer security (encrypted message body) over an open transport (http)
    3. Secured messages over a secured transport

    The last time I was doing WCF (about a year ago) the general recommendation from Microsoft seemed to be Message layer security over an open transport because of firewall / accessibility issues introduced when trying to secure the transport. However, this approach assumed that all parties involved were .NET / WCF capable. I believe it would be easier to consume on the device if it were an HTTPS transport level security, with clear XML or JSON message bodies. That way you can take advantage of all the stuff baked into CFNetwork and NSHTTPRequest that Apple has done.

    Once you get something working, you'll want to refer to the Enterprise Deployment Guide, and specifically the documentation on Over-the-Air Enrollment so that you can install the certificates on the devices. Remember, anything is possible, and don't be afraid to use one of those Apple support tickets that come with the program :)

    EDIT:

    I completely forgot to mention the GenericKeychain and CryptoExcercise examples

    EDIT 2:

    After I got downvoted for no apparent reason I re-read my response and realized I rambled a bit too much without actually answering your question about how to open a p12 file on the device. You ought to be able to simply [[UIApplication sharedApplication] openURL:urlToP12FileEitherLocalOrRemote]] and have it kick out to the OS for the installation procedure.

    0 讨论(0)
  • 2020-12-05 01:57

    You can also use ssl + user/pass authentication at the message level.

    0 讨论(0)
  • 2020-12-05 02:03

    I agree with Yaron Naveh's solution too, probably the best bet is to use SSL. I believe SSL/TLS encryption is better performance wise than message/XML based encryption in WCF too.

    I think the certificate would probably need to be from a trusted CA (certificate authority) for this to work though. From memory, I had difficulty with the iPhone SDK with self-signed certificates, but that may well have changed in the last year...

    0 讨论(0)
提交回复
热议问题