vau*_*lle 8 java security scala in-app-purchase
我有一个Scala后端,我想验证应用内购买收据,而不必依赖远程App Store服务,这会引入额外的延迟和额外的故障点.
因此,我想在本地验证收据中包含的PKCS#7签名.
Apple在下面的链接中有关于该主题的一些文档,但它使用iOS Objective-C API,并且我在尝试将其映射到Java安全API时遇到了一些麻烦.
从收据验证编程指南,代码清单1-4:
BIO *b_p7; /* The PKCS #7 container (the receipt) */
PKCS7 *p7; /* and the output of the verification. */
BIO *b_x509; /* The Apple root certificate, as raw */
X509 *Apple; /* data and in its OpenSSL representation. */
/* The root certificate for chain-of-trust verification. */
X509_STORE *store = X509_STORE_new();
/* Initialize b_out as an output BIO to hold the receipt payload */
BIO *b_out = BIO_new(BIO_s_mem());
/* Capture the content of the receipt file. */
p7 = d2i_PKCS7_bio(b_p7, NULL);
Apple = d2i_X509_bio(b_x509, NULL); /* Initialize b_x509 as an input BIO with a value of the Apple */
X509_STORE_add_cert(store, Apple); /* root certificate and load it into X509 data structure. */
/* Verify the signature. If the verification is correct, */
/* b_out will contain the PKCS #7 payload and rc will be 1. */
int rc = PKCS7_verify(p7, NULL, store, NULL, b_out, 0);
Run Code Online (Sandbox Code Playgroud)
我在网上找到了一些解决方案,使用不同的API(Oracle安全性,Sun安全性,Bouncy Castle)和同一API中的不同方法,但它们似乎都不起作用.对于没有太多安全知识的人来说,似乎没有一个能够找到原因.
令我困惑的一件事是,有些方法使用签名和未签名的内容来检查它们是否匹配,但其他方法(包括Apple的代码示例)仅使用签名的证书自行验证签名.哪种方法是正确的?
有人能够指出我正确的方向(正确的库,教程,代码示例等)?
谢谢!
| 归档时间: |
|
| 查看次数: |
613 次 |
| 最近记录: |