tikhop / TPInAppReceipt

Reading and Validating In App Purchase Receipt Locally.
MIT License
631 stars 93 forks source link

Can be used with sandbox receipts? #42

Closed andrefmsilva closed 4 years ago

andrefmsilva commented 4 years ago

Hi, I'm using it to validate sandbox receipts that i get with SKReceiptRefreshRequest but it fails...

Error Domain=NSOSStatusErrorDomain Code=-25318 "“Mac App Store and iTunes Store Receipt Signing” certificate is not trusted" UserInfo={NSLocalizedDescription=“Mac App Store and iTunes Store Receipt Signing” certificate is not trusted, NSUnderlyingError=0x2830b7b10 {Error Domain=NSOSStatusErrorDomain Code=-25318 "Certificate 0 “Mac App Store and iTunes Store Receipt Signing” has errors: Unable to build chain to root (possible missing intermediate);" UserInfo={NSLocalizedDescription=Certificate 0 “Mac App Store and iTunes Store Receipt Signing” has errors: Unable to build chain to root (possible missing intermediate);}}}

Can it be used with sandbox or not?

tikhop commented 4 years ago

Hi @Zasuk,

I will double check later today or, maximum, during the weekend. (@cupnoodle maybe you have some info related to the current issue?)

Thanks for you report!

cupnoodle commented 4 years ago

Hi @Zasuk , what is the platform of your app? is it macOS app or iOS app? If you dont mind, could you post your base64 encoded sandbox receipt data here? or email it to axelshaded@gmail.com , to help debugging.

So far I have tested the signature validation on my own iOS app in both sandbox/production environment.

andrefmsilva commented 4 years ago

hi @cupnoodle , i'm using it with iOS. i'll email you the base64 data. you need the value returned by the var base64 in InAppReceipt , right?

cupnoodle commented 4 years ago

Hi @Zasuk , Ah I see, yes the data in var base64 in InAppReceipt.

cupnoodle commented 4 years ago

Heya @Zasuk , I have found the issue, its because I didn't include WWDR (Worldwide developer certificate) in the chain of trust between iTunes certificate and Apple Root certificate.

I have submitted a pull request to fix this, but if you are in a hurry, you can modify the Validation.swift of this library, and add worldwideDevCertSec in the array in Line 169.

Screenshot 2019-12-08 at 11 34 38 PM

If you are using Cocoapods, after modifying the file, press "option + command + shift + K" to clean the build folder and build again.

Sorry for the inconvenience caused, hope this helps!

tikhop commented 4 years ago

@Zasuk, @cupnoodle I will accept PR in a bit and update cocoapods as well.

Thanks to both of you! P

tikhop commented 4 years ago

@Zasuk, @cupnoodle Just released a new version.

Thanks again. P

cupnoodle commented 4 years ago

Thanks @tikhop and @Zasuk !

andrefmsilva commented 4 years ago

awesome!! thank you guys

everwanna commented 4 years ago

Thank you @Zasuk @tikhop @cupnoodle