简体   繁体   English

在python中对Iap收据验证进行本地调试。

[英]Itunes iap receipt validation locally in python.

I am new to OpenSSL and I am trying to validate Itunes IAP receipts locally in python. 我是OpenSSL的新手,我正在尝试在python中本地验证Itunes IAP收据。

The Receipt Validation Programming Guide ( https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html ) says: 收据验证编程指南( 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. 最外面的部分(在图中标记为Receipt)是RFC 2315定义的PKCS#7容器,其有效负载使用ITU-T X.690定义的ASN.1(抽象语法表示法1)编码。 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? 任何想法如何使它工作?

My recommendation is to use an existing python package, itunes-iap is a good one: 我的建议是使用现有的python软件包,itunes-iap是一个很好的软件包:

https://pypi.python.org/pypi/itunes-iap https://pypi.python.org/pypi/itunes-iap

The only thing that will do that locally is this library: 唯一可以在本地执行此操作的是此库:

https://github.com/SilentCircle/iap-local-receipt https://github.com/SilentCircle/iap-local-receipt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM