I'm banging my head with receipt validation.
我用收据确认来敲我的头。
I'm in a phase where I validate if certificate is valid and I need to parse ASN1 file.
我在一个阶段,我验证证书是否有效,我需要解析ASN1文件。
Apple suggest to use asn1c, like :
苹果建议使用asn1c,比如:
#include "Payload.h" /* This header file is generated by asn1c. */
void *pld = NULL;
size_t pld_sz;
Payload_t *payload = NULL;
asn_dec_rval_t rval;
rval = asn_DEF_Payload.ber_decoder(NULL, &asn_DEF_Payload, (void **)&payload, pld, pld_sz, 0);
I already download asn1c-master.zip from: https://github.com/vlm/asn1c
我已经下载asn1c-master。zip:https://github.com/vlm/asn1c
Now I don't know how to install this lib into Xcode, and if I need some extra work or can I start as apple example after installing asn1c?
现在我不知道如何将这个lib安装到Xcode中,如果我需要一些额外的工作,或者我可以在安装asn1c后作为apple的例子开始?
Thanks for help.
谢谢你的帮助。
EDIT :
编辑:
I do as instructed in INSTALL file : in asn1c-master file I run in terminal :
我按照安装文件的指示做:在我在终端运行的asn1c-master文件中:
./configure
make
make check
make install
After that I create in separate folder file receipt.asn1
and add this text in it :
之后,我创建单独的文件夹文件收据。asn1并将此文本添加到其中:
ReceiptModule DEFINITIONS ::=
BEGIN
ReceiptAttribute ::= SEQUENCE {
type INTEGER,
version INTEGER,
value OCTET STRING
}
Payload ::= SET OF ReceiptAttribute
END
After that I run
在那之后我跑
asn1c -fnative-types receipt.ans1
But I gut out :
但我的直觉是:
-fnative-types: Deprecated option
ASN.1 grammar parse error near line 1 (token "{"): syntax error, unexpected '{', expecting TOK_typereference or TOK_capitalreference
Cannot parse "receipt.asn1"
1 个解决方案
#1
3
After following the instructions in http://github.com/vlm/asn1c/blob/master/INSTALL
遵循http://github.com/vlm/asn1c/blob/master/INSTALL的说明。
I do the following, in a new directory (i.e., Mac OS X folder):
我在一个新的目录中做如下操作(即:,Mac OS X文件夹):
# Terminal command line from: https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html#//apple_ref/doc/uid/TP40010573-CH1-SW3
asn1c -fnative-types receipt.ans1
# the file receipt.ans1 has contents from Listing 1-1 in the above URL
# converter-sample.c has a main. Don't want that!
rm converter-sample.c
rm Makefile.am.sample
Then, make sure to drag the resulting .c and .h files into an Xcode group, don't put the Mac folder directly into the project,or otherwise, the .c and .h files will not be added to the project. Thus, they won't build and you'll get linker errors
然后,确保将生成的.c和.h文件拖到Xcode组中,不要将Mac文件夹直接放入项目中,否则,.c和.h文件将不会被添加到项目中。这样,它们就不会构建,您就会出现链接错误。
#1
3
After following the instructions in http://github.com/vlm/asn1c/blob/master/INSTALL
遵循http://github.com/vlm/asn1c/blob/master/INSTALL的说明。
I do the following, in a new directory (i.e., Mac OS X folder):
我在一个新的目录中做如下操作(即:,Mac OS X文件夹):
# Terminal command line from: https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html#//apple_ref/doc/uid/TP40010573-CH1-SW3
asn1c -fnative-types receipt.ans1
# the file receipt.ans1 has contents from Listing 1-1 in the above URL
# converter-sample.c has a main. Don't want that!
rm converter-sample.c
rm Makefile.am.sample
Then, make sure to drag the resulting .c and .h files into an Xcode group, don't put the Mac folder directly into the project,or otherwise, the .c and .h files will not be added to the project. Thus, they won't build and you'll get linker errors
然后,确保将生成的.c和.h文件拖到Xcode组中,不要将Mac文件夹直接放入项目中,否则,.c和.h文件将不会被添加到项目中。这样,它们就不会构建,您就会出现链接错误。