I am validating subcription from an Apple’s IAP Receipt utilizing app-store-server-library-node.
All the things is okay throughout dev in Apple’s “Sandbox” mode.
As soon as I add my app and run it from a testFlight construct I’ve go this error:
Error: error:0480006C:PEM routines::no begin line
at new X509Certificate (node:inside/crypto/x509:119:21)
at /decide/app/node_modules/@apple/app-store-server-library/jws_verification.ts:55:65
at Array.map ()
at new SignedDataVerifier (/decide/app/node_modules/@apple/app-store-server-library/jws_verification.ts:55:53)
Right here is how I provoke the decision :
(keys and ids have been modified for apparent safety motive)
const issuerId = '6f1337a3-1234-4929-9ccd-774e8c02fa18';
const keyId = 'FG7N3NY68Y';
const bundleId = 'com.appname.app';
const teamId = '6JZPD4JMSJ';
// appAppleId is required when the surroundings is Manufacturing
const appAppleId = teamId+"."+bundleId;
const appleEnv = Surroundings.PRODUCTION;
const filePath = path.be part of(ROOT_FOLDER, `/keys/AppleApi_AuthKey_${keyId}.p8`);
const privateKey = fs.readFileSync(filePath, 'utf8');
const consumer = new AppStoreServerAPIClient(privateKey, keyId, issuerId, bundleId, appleEnv);
const appleRootCAs = [
fs.readFileSync(path.join(ROOT_FOLDER, '/keys/AppleRootCer/AppleIncRootCertificate.cer')),
fs.readFileSync(path.join(ROOT_FOLDER, '/keys/AppleRootCer/AppleComputerRootCertificate.cer')),
fs.readFileSync(path.join(ROOT_FOLDER, '/keys/AppleRootCer/AppleRootCA-G2.cer')),
fs.readFileSync(path.join(ROOT_FOLDER, '/keys/AppleRootCer/AppleRootCA-G3.cer')),
];
const enableOnlineChecks = true;
console.log('privateKey = ', privateKey);
const verifier = new SignedDataVerifier(appleRootCAs, enableOnlineChecks, appleEnv, bundleId, appAppleId);
I am first making an attempt to run in Manufacturing env then in sandbox as requested in apple’s documentation.
The information are appropriately learn. Login non-public key reveals:
privateKey = —–BEGIN PRIVATE KEY—–
MIGTAbEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQg4n35kqKOEJA5ITBZ
lf5QfWlaj1re4R60jFflAmzfJQKgCgYIKoZIzj0DABehRANCAATvNxWUh/WGfw+q
OW1kMsTRNyBN7IwS861VjFvtQKN7r8wlvG1jTw+vTpsv/84xZw/H+IDmFLnOkAbS
yRfk1PcT
—–END PRIVATE KEY—–
extra log values :
enableOnlineChecks : true
surroundings : Manufacturing
bundleId : com.appname.app
appAppleId : 6JZPD4JMSJ.com.appname.app <= is that this appId format
right ?
(All keys and appname/ group id have been change for apparent safety motive)
Are you able to see something I do incorrect ?
Ought to we “enableOnlineChecks” ?
Thanks in your assist.