我下载了AppleRootCertificate.cer,现在我试着检查我的应用程序内收据证书是否有效(和苹果一样)。
我就像他的WWDS视频里的苹果一样。
BIO *b_receipt = BIO_new_mem_buf((void *)[receipt bytes], (long)[receipt length]);
BIO *b_x509 = BIO_new_mem_buf((void *)[certificateData bytes], (long)[certificateData length]);
// Convert receipt data to PKCS #7 Representation
PKCS7 * p7 = d2i_PKCS7_bio(b_receipt, NULL);
// Create the certificate store for matching white Apple cerif.
X509_STORE * store = X509_STORE_new();
X509 * appleRootCA = d2i_X509_bio(b_x509, NULL);
X509_STORE_add_cert(store, appleRootCA);
// Verify the Signature
BIO * b_receiptPayload = BIO_new(BIO_s_mem());
int result = PKCS7_verify(p7, NULL, store, NULL, b_receiptPayload, 0);
NSLog(@"Result == %i", result); 但结果总是0而不是1。
我做错什么了?
发布于 2014-03-31 06:19:48
正如#noloader所建议的,我使用ERR_get_error()打印错误。
当我得到:Error:0D0C50A1:lib(13):func(197):reason(161)时,我搜索它,发现我需要在上面添加这一行:
OpenSSL_add_all_algorithms();这解决了我所有的问题
https://stackoverflow.com/questions/22716149
复制相似问题