Reputation: 3835
If I implement Apple's VerificationController.m example, is it still necessary to do server side receipt verification? Also, if you do server side, then there seems to be no reason to implement VerificationController.m since you're not contacting Apple's servers from the device.
Best case, I'd rather only implement VerificationController.m because I don't have a great way to run my own https server. Is that enough? The App runs on iOS 5+
Upvotes: 2
Views: 1440
Reputation: 33592
This is trickier than it first appears, so I'll probably get this subtly wrong, but here goes:
The original attack relies on two weaknesses in iOS ≤ 5.x:
This allows the user/attacker to pretend to be the App Store server and present a valid receipt for someone else's purchase.
VerificationController can't fix the first weakness (it can't change how StoreKit talks to Apple); it mostly just fixes the second. It also seems to check far more things than ought to be necessary (but I could just be plain wrong here), including a bunch of things that StoreKit probably already checks.
Client-side verification doesn't protect against someone hacking the client, which is pretty easy on a jailbroken phone. This isn't really an issue if the thing being purchased could be hacked just as easily (e.g. ammo for a game/turning off ads).
Server-side verification is desirable when the server provides the thing being purchased (e.g. DLC/Skype credit/FarmCoins).
In general, do the verification at the point where you convert the receipt into the purchased item.
There are a few issues with VerificationController, though:
//Validation suceeded. Unlock content here.
if the receipt-verification connection fails, which could easily happen over a poor 3G connection. This might not be an issue for non-consumable transactions (I think restored transactions get a new transaction ID), but means consumables get lost forever. You can postpone calling -[SKPaymentQueue finishTransaction:]
until receipt-verification succeeds, but this will leave incomplete transactions in the queue — hopefully they eventually expire without charging the user.-connection:didReceiveData:
returns all the response data. This might be true to implementation details of the server and NSURLConnection, but relying on this is unwise.Upvotes: 3