russell-archer / StoreHelper

Implementing In-App Purchases with StoreKit2 in Xcode 13 - 15 using SwiftUI, Swift 5.7 - 5.9, iOS 15 - 17 and macOS 12 - 14. Also supports tvOS and visionOS.
MIT License
410 stars 48 forks source link

Certificate issue on device #49

Closed EPage-Ed closed 1 year ago

EPage-Ed commented 1 year ago

iOS 16.4 (though same problem with iOS 16.3), Xcode 14.2 and 14.3.

Doing a non-consumable in-app purchase. Code was running fine a few months ago, and recently started on an update, and encounter this issue. Running on simulator works as before - purchase validates and updates just fine. Running on a device (iPhone 12 Pro with 16.3 or 16.4) fails validation with:

2023-04-01 00:16:39.288226-0700 XXXXX[27827:2726419] [Default] Failed to verify certificate chain due to client recoverable failure: Error Domain=NSOSStatusErrorDomain Code=-67843 "“StoreKit Testing in Xcode” certificate is not trusted" UserInfo={NSLocalizedDescription=“StoreKit Testing in Xcode” certificate is not trusted, NSUnderlyingError=0x28259a550 {Error Domain=NSOSStatusErrorDomain Code=-67843 "Certificate 0 “StoreKit Testing in Xcode” has errors: Root is not trusted;" UserInfo={NSLocalizedDescription=Certificate 0 “StoreKit Testing in Xcode” has errors: Root is not trusted;}}} 2023-04-01 00:16:39.289279-0700 XXXXXX[27827:2726418] [Default] Failed to verify signature for Transaction, will assume invalid: failedToVerifyCertificateChain

russell-archer commented 1 year ago

Thanks for letting me know. I’ll investigate today and let you know what I see.  Russell Sent from my iPhone On 1 Apr 2023, at 08:52

russell-archer commented 1 year ago

I can't reproduce this I'm afraid. This is what I did to reproduce the issue:

Setup:

StoreKit testing on real device:

Sandbox testing on real device:

I also removed the app from another real device and re-installed from the real App Store. Previous purchases were correctly recognized, auto-restored and validated.

So, it passes the "it all works on my machine" test! :-)

But what could be causing your issues? Actually, those errors about "StoreKit Testing in Xcode certificate is not trusted" look familiar. I seem to remember seeing something similar about 6 months ago, but only related to macOS builds. I never got to the bottom of it and a new version of Xcode seemed to cure it.

A couple of ideads:

  1. I wonder what would happen if you create a completely new, very simple demo app that uses StoreKit testing WITHOUT using StoreHelper. If you see the same errors it would indicate something related to your setup.
  2. Have you tried using sandbox testing? I have a feeling that might work because it's using a different certificate for validating transactions.

Let me know how you get on - I'm happy to help if I can.

Russell

EPage-Ed commented 1 year ago

Success! You gave me a clue about the Sandbox account. I think my old one was just "old". Created a new one (a bit of a pain), turned off .storekit file, ran on device from Xcode, did purchase and it worked. Thanks!

Great response and thanks for getting to it so quickly. Can I give the repo a second star? ;-)

russell-archer commented 1 year ago

Excellent! So glad you got it sorted out!