I am new to OpenSSL and I am trying to validate Itunes IAP receipts locally in python.
The Receipt Validation Programming Guide (https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html) says:
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.
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
This test seems to generate an error:
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')]
Any ideas how to get this working?