我目前正在尝试实施一种形式的本地收据验证,如apple's developer portal所述:

但是我遇到了障碍。我相信收据中的证书无法正确针对苹果根CA进行验证。


  87937:错误:04077068:RSA例程:RSA_verify:错误的签名:rsa_sign.c:263:
  87937:错误:0D0C5006:asn1编码例程:ASN1_item_verify:EVP库:a_verify.c:179:
  87937:错误:21075075:PKCS7例程:PKCS7_verify:证书验证错误:pk7_smime.c:244:验证错误:证书签名失败


运行gdb表示失败发生在这里:


  (gdb)bt
  
  #0 RSA_verify(dtype = 64,m = 0xbfffe1b4“”,m_len = 20,sigbuf = 0x37af90“”,siglen = 256,rsa = 0x37ca80)在rsa_sign.c:263
  
  在p_verify.c处的EVP_VerifyFinal(ctx = 0xbfffe2b0,sigbuf = 0x37af90“”,siglen = 256,pkey = 0x37ca60)中为#1 0x0013e6fa
  
  ASN1_item_verify中的#2 0x00152b38(它= 0x20b118,a = 0x37a5b0,签名= 0x37a5c0,asn = 0x37a460,pkey = 0x37ca60)在a_verify.c:176
  
  X509_verify中的#3 0x0018e73c(a = 0x37a400,r = 0x37ca60)在x_all.c:76
  
  #4 0x001866ef internal_verify(ctx = 0xbffff5a8)在x509_vfy.c:998
  
  X509_verify_cert中的#5 0x00185ad9(ctx = 0xbffff5a8)在x509_vfy.c:305
  
  pk7_smime.c:240上的PKCS7_verify中的#6 0x001b4f1d(p7 = 0x3792c0,certs = 0x0,store = 0x379160,indata = 0x0,out = 0x379260,flags = 0)
  
  #7 0x00001dd6在pkcs7_decrypt.c:42的main()中
  当前语言:自动;目前很少
  (gdb)


它无法根据中间证书“ / C = US / O = Apple Inc./OU=Apple Worldwide Developer Relations / CN = Apple Worldwide Developer Relations Certification Authority”来验证根CA的发布密钥。

尽管我可能没有正确执行此操作,但针对中间证书运行openssl verify直接产生了相似的结果:


  bbooth @ Bills-MacBook-Air:forge $ openssl verify -verbose -CAfile apple.pem devrel.pem
  
  devrel.pem:/ C = US / O = Apple Inc./OU=Apple Worldwide Developer Relations / CN = Apple Worldwide Developer Relations Certification Authority
  
  在0深度查找时出现错误7:证书签名失败
  
  88161:错误:04077068:RSA例程:RSA_verify:错误签名:/SourceCache/OpenSSL098/OpenSSL098-47.2/src/crypto/rsa/rsa_sign.c:263:
  
  88161:错误:0D0C5006:asn1编码例程:ASN1_item_verify:EVP库:/SourceCache/OpenSSL098/OpenSSL098-47.2/src/crypto/asn1/a_verify.c:179:
  
  bbooth @ Bills-MacBook-Air:forge $


这是我在OSX中运行的代码:

fp = fopen("AppleIncRootCertificate.cer", "rb");
fread(buf, sizeof(buf), 1, fp);
b_x509 = BIO_new_mem_buf(buf, 1215);

Apple = d2i_X509_bio(b_x509, NULL);
fclose(fp);

X509_STORE *store = X509_STORE_new();
X509_STORE_add_cert(store, Apple);

bio = BIO_new_file("receipt.cer", "r");
p7 = d2i_PKCS7_bio(bio, NULL);
BIO_free(bio);

ERR_print_errors_fp(stdout);
bio = BIO_new_file("receipt.dec", "w");
PKCS7_verify(p7, NULL, store, NULL, bio, 0);


随时查看the receipt
我必须承认,我是这个问题涉及的几乎所有系统的新手,我们将不胜感激!

最佳答案

因此,解决方案很简单,即收据以某种方式损坏(尽管能够对其进行解析。)将此收据发送到Appstore收据验证程序会产生收据数据格式错误。

我在收据上重试了代码,该收据在Apple服务器上进行了验证,没有错误,并且工作正常。

关于ios - iOS中的App购买收据AppleInc根CA验证,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25152705/

10-16 20:06