RevenueCat/storekit2-demo-app

X5C Verification API Changed

Opened this issue · 0 comments

Hi, thank you for putting together the tutorial. In following a long I did run into some issues with the X5C payload validation because it looks like the API to .verifyJWSWithX5C() was still in flux at the time of writing.

After a bit of stumbling around I think I figured out a suitable approach for validation:

let appleRootCert = """
-----BEGIN CERTIFICATE-----
MIICQzCCAcmg...
6BgD56KyKA==
-----END CERTIFICATE-----
"""

...

let notification = try req.content.decode(SignedPayload.self)
let x5cVerifier = try X5CVerifier(rootCertificates: [appleRootCert])
let payload = try x5cVerifier.verifyJWS(notification.signedPayload, as: NotificationPayload.self)

I'll see if I can get a PR up to change this in the repo later, but wanted to make sure others had a little help if they encounter the same issue.