gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 06:02:14 25 4
gpt4 key购买 nike

我是 OpenSSL 的新手,我正在尝试在 python 中本地验证 Itunes IAP 收据。

收据验证编程指南(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

这个测试似乎产生了一个错误:

    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 是一个很好的包:

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

关于python - 在 python 中本地进行 Itunes iap 收据验证。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24216622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com