title: Itunes iap receipt validation locally in python.
body: <p>I am new to OpenSSL and I am trying to validate Itunes IAP receipts locally in python. </p>
  
  <p>The Receipt Validation Programming Guide (<a href="https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html" rel="nofollow">https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html</a>) says:</p>
  
  <blockquote>
    <p>The outermost portion (labeled Receipt in the figure) is a PKCS #7 container, as defined by RFC 2315, with its payload encoded using ASN.1 (Abstract Syntax Notation One), as defined by ITU-T X.690. The payload is composed of a set of receipt attributes. Each receipt attribute contains a type, a version, and a value.</p>
  </blockquote>
  
  <pre><code>import OpenSSL
  
  f = open('sample_IAP_receipt_base64.txt', 'r').read()
  
  type = OpenSSL.crypto.FILETYPE_ASN1
  data = OpenSSL.crypto.load_pkcs7_data(type, f)
  print f
  </code></pre>
  
  <p>This test seems to generate an error: </p>
  
  <pre><code>    data = OpenSSL.crypto.load_pkcs7_data(type, f)
  OpenSSL.crypto.Error: [('asn1 encoding routines', 'ASN1_CHECK_TLEN', 'wrong tag'), ('asn1 encoding routines', 'ASN1_ITEM_EX_D2I', 'nested asn1 error')]
  </code></pre>
  
  <p>Any ideas how to get this working?</p>