我是 OpenSSL 的新手,我正在尝试在 python 中本地验证 Itunes IAP 收据。
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
这个测试似乎产生了一个错误:
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')]
有什么想法可以让它发挥作用吗?
请您参考如下方法:
我的建议是使用现有的 python 包,itunes-iap 是一个很好的包:
