问题
I'm using Receigen (http://receigen.etiemble.com/) to do receipt validation for one of my MacOS apps. This has worked beautifully for several years, but something has changed. I haven't made an update to this app for a year or so and submitted a change but it was rejected because the receipt validation wasn't working.
When I try to test the receipts locally, it pops up the App Store login, I enter my email+password, and then I get the "app is damaged" message.
I used the Receigen Code Assistant to generate validation code (it generates receipt validation code and randomizes as much as it can so you can't just easily crack every app that uses receigen).
I'm using macOS 10.14.3 and Xcode 10.2.
This is the header from my receigen generated code:
//
// This code was generated by RECEIGEN 4.0.4 on 2019-04-08 15:54:01 and will use:
//
// Bundle Identifier : com.inadaydevelopment.mac10biiFinancialCalculator
// Bundle Version : 2.1.0
// Receipt Identifier : com.inadaydevelopment.mac10biiFinancialCalculator
// Receipt Version : 2.1.0
//
// Language : ObjC
// Platform : OSX
// Code Prefix : ReceiptValidation
// Success Behavior : RunApplication
// Failure Behavior : ExitWith173
//
// Certificate Name : Apple Root CA
// Certificate Fingerprint : 611E5B662C593A08FF58D14AE22452D198DF6C60
// Signer Certificate OID : 1.2.840.113635.100.6.11.1
//
// OpenSSL Version : 1.0
//
// This generated code has to be linked with OpenSSL libcrypto (either statically or dynamically)
// Refer to the website for more details and specific cases.
//
I have verified that the Bundle Id and Version match what I have in XCode (the text field isn't long enough, but it DOES start with com.inaday...):
I looked through Receigen's diagnostic page to see the possible fixes for this, but nothing helped:
1) I looked/searched through my console for any "storeagent" entries and I never find any. Perhaps the Diagnostics page has info for an older version of macOS?
2) I did the "killall" and "rm -r" commands to fix any caching problems associated with the damaged message. I also rebooted several times.
3) I looked inside the app package and I didn't see any receipt.
4) I deleted the only other copy of the app that I know of (the one I've installed from the App Store) and tried everything again. Same problem.
5) Tried removing the Container. Same problem.
6) I tried "sudo pkill -f CommerceKit". Same problem.
This is what I found in my console:
ReceiptRefreshRequest: Error fetching receipt for /Users/kenny/Library/Developer/Xcode/DerivedData/10bii_Financial_Calculator-edfoaceclymbdsazqdpinclhsejp/Build/Products/Debug/10bii Financial Calculator.app - Error Domain=com.apple.commerce.server Code=500317 "(null)"
Here's the full section from the console:
default 11:52:42.776265 -0700 commerce StoreSession: StatusCode: 200; <private>; Environment: SB; URL: https://p100-sandbox.itunes.apple.com/WebObjects/MZFinance.woa/wa/createAppReceipt
debug 11:52:42.776776 -0700 commerce looked up value <private> for key PrimaryAccount:1 in CFPrefsPlistSource<0x7fe4eb803860> (Domain: com.apple.appstore.commerce, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No)
debug 11:52:42.776811 -0700 commerce looked up value <private> for key KnownAccounts:1 in CFPrefsPlistSource<0x7fe4ea6058a0> (Domain: com.apple.commerce, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No)
debug 11:52:42.776909 -0700 commerce Handling response <private> for URL <private>...
debug 11:52:42.776943 -0700 commerce No handling for HTTP status code 200 in response for URL <private>
default 11:52:42.777268 -0700 storeuid ReceiptRefreshRequest: Error fetching receipt for /Users/kenny/Library/Developer/Xcode/DerivedData/10bii_Financial_Calculator-edfoaceclymbdsazqdpinclhsejp/Build/Products/Debug/10bii Financial Calculator.app - Error Domain=com.apple.commerce.server Code=500317 "(null)"
debug 11:52:42.777338 -0700 storeuid Bundle: <private>, key: APP_IS_DAMAGED_TITLE, value: , table: MacAppStore, localizationName: (null), result: APP_IS_DAMAGED_TITLE
debug 11:52:42.777400 -0700 storeuid Bundle: <private>, key: APP_IS_DAMAGED_TITLE, value: , table: Localizable, localizationName: (null), result: “%@” is damaged and can’t be opened. Delete “%@” and download it again from the App Store.
debug 11:52:42.777427 -0700 storelegacy Bundle: <private>, key: com.apple.commerce.server, value: com.apple.commerce.server, table: Error, localizationName: (null), result: com.apple.commerce.server
debug 11:52:42.777496 -0700 storeuid Resource lookup at <private>
Request : appStore type: icns
Result : file:///System/Library/PrivateFrameworks/CommerceKit.framework/Resources/appStore.icns
debug 11:52:42.777471 -0700 storelegacy Bundle: <private>, key: The operation couldn\U2019t be completed. (%@ error %ld.), value: The operation couldn\U2019t be completed. (%@ error %ld.), table: Error, localizationName: (null), result: The operation couldn’t be completed. (%1$@ error %2$ld.)
debug 11:52:42.777544 -0700 storeuid Bundle: <private>, key: OK, value: , table: MacAppStore, localizationName: (null), result: OK
default 11:52:42.777540 -0700 storelegacy StoreLegacy: Failed to renew receipt for application at path /Users/kenny/Library/Developer/Xcode/DerivedData/10bii_Financial_Calculator-edfoaceclymbdsazqdpinclhsejp/Build/Products/Debug/10bii Financial Calculator.app : 'The operation couldn’t be completed. (com.apple.commerce.server error 500317.)'
回答1:
Found the answer here, replicated below in case the original goes away: https://forums.developer.apple.com/thread/92419
The problem was that I was trying to login using my normal iTunes Account.
... the user must use a Sandbox Test User Apple ID, not their own Apple ID which was not clear to me at the time. Also, I have found that the user needs to log out of the Mac App Store with their own Apple ID in order to be able to even enter the Sandbox Test User Apple ID when requested.
However, the Sandbox Test User accounts are Country specific. So you need a Sandbox Test User per country. And right now, I have very similar error messages for a user in a new country. Am probably going to have to use another DTS request to figure it out.
来源:https://stackoverflow.com/questions/55600173/mac-app-store-testing-receipt-validation-from-receigen-app-is-damaged-and-can