0
我正在使用應用內購買在我的應用程序...現在我想驗證收據,並驗證收據簽名我使用AppDelegate下面的代碼(按順序要知道,如果用戶啓動應用程序時)Xcode驗證收據簽名錯誤
實際的代碼來自WWDC 2013已經購買了它 - 會話308 ;-)
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receiptData = [NSData dataWithContentsOfURL:receiptURL];
NSData *certificateData = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"AppleIncRootCertificate" withExtension:@"cer"]];
/* The PKCS #7 container (the receipt) and The Apple root certificate. */
BIO *b_receipt = BIO_new_mem_buf((void *) [receiptData bytes], (int)[receiptData length]);
BIO *b_x509 = BIO_new_mem_buf((void *)[certificateData bytes], (int)[certificateData length]);
// Convert receipt data to PKCS #7 Representation
PKCS7 *p7 = d2i_PKCS7_bio(b_receipt, NULL);
/* Create the root certificate */
X509_STORE *store = X509_STORE_new();
X509 *appleRootCA = d2i_X509_bio(b_x509, NULL);
X509_STORE_add_cert(store, appleRootCA);
/* Verify the signature. If the verification is correct, b_receiptPayload will contain the PKCS #7 payload and result will be 1. */
BIO *b_receiptPayload = BIO_new(BIO_s_mem());
int result = PKCS7_verify(p7, NULL, store, NULL, b_receiptPayload, 0);
if (result == 1)
{
NSLog(@"Receipt Signature is valid");
} else {
unsigned long error = ERR_get_error();
const char* error_str = ERR_error_string(error, NULL);
NSLog(@"OpenSSL Error: %s",error_str);
}
,但我總是得到以下OpenSSL的錯誤:錯誤:2006F079 :lib(32):func(111):reason(121)
我已經googl它但沒有任何結果......任何建議?
驗證收據簽名的另一種方法是?
預先感謝您的合作...
我使用這個庫 - https://github.com/robotmedia/RMStore。這裏是如何使用收據驗證的信息https://github.com/robotmedia/RMStore/wiki/Receipt-verification – Traveler
謝謝,我會檢查它... – jankoesp