views:

229

answers:

3

Hi,

How can i make sure only my iphone app is allowed to use my app engine application for sending and receiving data? I probably have to use a secret key, but i don't know how. Can i just use post/get to send my static key over https? Or do i need to use some dynamic secret key algorithm?

Any help would be appreciated! Bjorn

A: 

I'm not totally sure what yo are trying to accomplish.

But, having shared secrets or API keys inside your iPhone app is generally a bad idea.

You are talking about your own AppEngine application. Why don't you create a simple (JSON based) web service on the AppEngine side that your app talks to? I doubt there is any need to directly use your AppEngine credentials from your iPhone app.

If this does not answer your question, please provide more details.

St3fan
i have a api web service, but i only want my iphone app to talk with it. In the current situation the API is available to the whole world, so anyone can send bad data to it and my database will be filled with data i dont want to have.
Bjorn
+2  A: 

Assuming you think you can keep the secret on the iPhone app from being discovered, what you need is an HMAC. For every request you make, pass the text of the request into a function like HMAC-SHA1, with your secret key as the key, and add the result to the request you make. When the server receives the request, perform the same operation, and verify that the HMACs match.

Nick Johnson
This also gives you a security problem. What if somebody intercepts the HMAC and uses it maliciously to post exactly the same data to your service hundreds of times, thus duplicating your data?
Rippo
Then you have a problem - the exact same problem you have with any other scheme. Hence my opening comment "Assuming you think you can keep the secret on the iPhone app from being discovered...".
Nick Johnson
Sorry, I misread your comment first time around. You're correct - you need to include a nonce and/or timestamp to prevent replay attacks. Of course, this may be a non-issue depending on his threat model.
Nick Johnson
or just use SSL to stop snooping....
Rippo
A: 

Use a SSL certificate on your web service as any data passed to this is encrypted.

An encrypted SSL connection requires all information sent between a client and a server to be encrypted by the sending software and decrypted by the receiving software, protecting private information from interception over the Internet.

Also on every call to the service send up a single guid that you have defined along with your data. This guid has to be validated before the web service performs any action. To lock down even further you can create a service that generates a guid which needs to be passed back up for any subsequent calling service.

Also make sure you don't allow anybody to see your wsdl on the server else they can guess your parameters.

A SSL ceritifcate from RapidSSL costs $17 a year so the cost is nothing to worry about.

Rippo
This doesn't help - an SSL certificate validates the identity of the service, not the client. He could embed a client certificate, but App Engine has no way of verifying client certs.
Nick Johnson
Did you read through my post? The SSL is just a way to stop people snooping what you are actually sending across between the client and server. Passing a guid through seems like a good way.
Rippo