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.
Apple suggest to use asn1c, like :
#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
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?
Thanks for help.
EDIT :
I do as instructed in INSTALL file : in asn1c-master file I run in terminal :
./configure
make
make check
make install
After that I create in separate folder file receipt.asn1
and add this text in it :
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"
After following the instructions in http://github.com/vlm/asn1c/blob/master/INSTALL
I do the following, in a new directory (i.e., Mac OS X folder):
# 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