在python中本地验证Itunes iap收据。

2024-10-05 14:26:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我是OpenSSL的新手,我正在尝试用python在本地验证itunesiap回执。在

收据验证编程指南(https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html)说:

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

此测试似乎生成了一个错误:

^{pr2}$

有什么办法让它工作吗?在


Tags: ofthedatabyisastypecrypto