title: Mac App Store testing receipt validation (from receigen) "app is damaged and can't be opened."
body: <p>I'm using Receigen (<a href="http://receigen.etiemble.com/" rel="noreferrer">http://receigen.etiemble.com/</a>) 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.</p>
  
  <p>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.</p>
  
  <p>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). </p>
  
  <p>I'm using macOS 10.14.3 and Xcode 10.2. </p>
  
  <p>This is the header from my receigen generated code:</p>
  
  <pre><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.    
  //
  </code></pre>
  
  <p>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...):</p>
  
  <p><a href="https://i.stack.imgur.com/Q9wT5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q9wT5.png" alt="enter image description here"></a></p>
  
  <p>I looked through <a href="http://receigen.etiemble.com/guides-diagnostic.html" rel="noreferrer">Receigen's diagnostic page</a> to see the possible fixes for this, but nothing helped:</p>
  
  <p>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? </p>
  
  <p>2) I did the "killall" and "rm -r" commands to fix any caching problems associated with the damaged message. I also rebooted several times.</p>
  
  <p>3) I looked inside the app package and I didn't see any receipt. </p>
  
  <p>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.</p>
  
  <p>5) Tried removing the Container. Same problem.</p>
  
  <p>6) I tried "sudo pkill -f CommerceKit". Same problem. </p>
  
  <p>This is what I found in my console:</p>
  
  <blockquote>
    <p>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)"</p>
  </blockquote>
  
  <p>Here's the full section from the console:</p>
  
  <pre><code>default 11:52:42.776265 -0700   commerce    StoreSession: StatusCode: 200; &lt;private&gt;; Environment: SB; URL: https://p100-sandbox.itunes.apple.com/WebObjects/MZFinance.woa/wa/createAppReceipt
  debug   11:52:42.776776 -0700   commerce    looked up value &lt;private&gt; for key PrimaryAccount:1 in CFPrefsPlistSource&lt;0x7fe4eb803860&gt; (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 &lt;private&gt; for key KnownAccounts:1 in CFPrefsPlistSource&lt;0x7fe4ea6058a0&gt; (Domain: com.apple.commerce, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No)
  debug   11:52:42.776909 -0700   commerce    Handling response &lt;private&gt; for URL &lt;private&gt;...
  debug   11:52:42.776943 -0700   commerce    No handling for HTTP status code 200 in response for URL &lt;private&gt;
  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: &lt;private&gt;, key: APP_IS_DAMAGED_TITLE, value: , table: MacAppStore, localizationName: (null), result: APP_IS_DAMAGED_TITLE
  debug   11:52:42.777400 -0700   storeuid    Bundle: &lt;private&gt;, 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: &lt;private&gt;, 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 &lt;private&gt;
      Request       : appStore type: icns
      Result        : file:///System/Library/PrivateFrameworks/CommerceKit.framework/Resources/appStore.icns
  debug   11:52:42.777471 -0700   storelegacy Bundle: &lt;private&gt;, 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: &lt;private&gt;, 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.)'
  </code></pre>