Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receipt validation tests fail with invalid certificate chain #90

Closed
hannesoid opened this issue Feb 10, 2023 · 3 comments · Fixed by #91
Closed

Receipt validation tests fail with invalid certificate chain #90

hannesoid opened this issue Feb 10, 2023 · 3 comments · Fixed by #91

Comments

@hannesoid
Copy link
Contributor

Related: #89

Some of the example receipts used in the tests are signed by now expired certificates, leading the tests to fail.
Ideally the example receipts should be updated.

@lukaskubanek
Copy link
Contributor

Oh, that’s unfortunate. Happens in my project as well. Is there a way to re-sign the same receipt files or does one have to collect new ones? Also, have you thought about a way to circumvent the logic of reporting invalid certificates just for tests?

@hannesoid
Copy link
Contributor Author

Unfortunately I think we have to collect new ones if the goal is to test if AppReceiptValidator does the right thing based on the the Apple certificate chain. As we can't sign as Apple.

If you do want to resign it, you would probably need a (trusted) valid certificate + private key to start with, resign the receipts somehow and put it in the AppReceiptValidator parameters parameters.signatureValidation: SignatureValidation = .shouldValidate(rootCertificateOrigin: myRootCertificate). But I don't have an example how this really plays out.

Conceptually though, I think it should be enough to update the tests in the AppReceiptValidator package in this repository, and in your own project's tests, if it is too cumbersome too collect receipts again, you can disable the signature check:

let result = AppReceiptValidator().validateReceipt(parameters: .init().with {
     // this test uses a receipt of which a certificate has expired, we just want to check the parsing part so we can neglect this here
     $0.signatureValidation = .skip 
     
})

@lukaskubanek
Copy link
Contributor

if it is too cumbersome too collect receipts again, you can disable the signature check

That’s a great hint, thanks! I’ll probably collect as many new receipts as I can and fall back to skipping signature checks for all the other test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants