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

"Certificate validation failed" error when decoding transactions #49

Open
DePasqualeOrg opened this issue Mar 9, 2024 · 3 comments
Open

Comments

@DePasqualeOrg
Copy link
Contributor

I'm decoding transactions as follows, but I get the error "Certificate validation failed". I've verified that the environment variable is correct for the development environment. I haven't tried it in production yet. Any idea why this would be failing in the development environment?

import type { Action } from '@sveltejs/kit';
import { json } from '@sveltejs/kit';
import { decodeTransactions, APPLE_ROOT_CA_G3_FINGERPRINT } from 'app-store-server-api';
import { ENVIRONMENT } from '$env/static/private';

// https://developer.apple.com/documentation/xcode/setting-up-storekit-testing-in-xcode#Prepare-to-validate-receipts-in-the-test-environment
const LOCAL_ROOT_FINGERPRINT = 'FF:0B:A3:<redacted>';
const fingerprint = (ENVIRONMENT.toLowerCase() === 'production') ? APPLE_ROOT_CA_G3_FINGERPRINT : LOCAL_ROOT_FINGERPRINT;

export const POST: Action = async ({ request }) => {
  const requestData: { transactions: string[] } = await request.json();
  const decodedTransactions = await decodeTransactions(requestData.transactions, fingerprint);
  // Error: Certificate validation failed
  console.log(decodedTransactions);
  return json({});
};
@DePasqualeOrg
Copy link
Contributor Author

I've now verified that it works in production but not in the development environment.

@agisboye
Copy link
Owner

Are you using the SHA256 fingerprint?

I know a few people have had success validating local transactions (see #25) but I'm not sure if something has changed in Xcode since then. If it's not working I'm happy to take a look but it might be a while before I have the time.

@DePasqualeOrg
Copy link
Contributor Author

DePasqualeOrg commented Mar 13, 2024

Yes, I copied the SHA-256 fingerprint from the certificate in Xcode and verified that it is correct.

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

No branches or pull requests

2 participants