pkpass没有在模拟器中显示

时间:2014-11-21 08:15:47

标签: ios json passbook passkit

我正在使用Passbook实现ios应用程序。所以我已经实现了ASP.net服务器来生成一个传递。传递是从服务器端成功生成的。当我双击我的mac中的pass.pkpass文件时,传递查看器显示我从服务器创建的传递。但是当我试图将它拖到IOS模拟器时,据说“safari无法下载此文件”。我试过通过重新生成证书。但没有任何效果。

这是我的pass.json文件

  {
  "passTypeIdentifier": "<mypassIdenttity>",
  "formatVersion": 3,
  "organizationName": "<my organization name>",
  "serialNumber": "<my serial number>",
  "teamIdentifier": "<my team identifier>",
  "description": "123",
  "foregroundColor": "rgb(255,255,255)",
  "backgroundColor": "rgb(55,117,50)",
  "logoText": "Zekes",
  "barcode": {
  "message": "123456789",
  "format": "PKBarcodeFormatPDF417",
  "messageEncoding": "iso-8859-1"
  },
  "storeCard": {
  "primaryFields": [
  {
    "key": "balance",
    "label": "remaining balance",
    "value": 21.75
  }
 ],
 "auxiliaryFields": [
  {
    "key": "deal",
    "label": "Deal of the Day",
    "value": "Lemons"
  }
]
 }
}

这是我的manifest.json

 {
  "pass.json": "285c63c6580d946eb360e0c6e68d1fa072ea20e9",
  "logo.png": "25de09e2d3b01ce1fe00c2ca9a90a2be1aaa05cf",
  "icon.png": "0296b01347b3173e98438a003b0e88986340b2d8",
  "icon@2x.png": "5afd9585b08c65fdf105a90c8bd643407cba2787",
  "strip.png": "736d01f84cb73d06e8a9932e43076d68f19461ff",
  "strip@2x.png": "468fa7bc93e6b55342b56fda09bdce7c829d7d46"
 }

我已将传递证书导出为P12文件,将privateKey导出为P12文件。并将它们复制到我的项目路径[在服务器实现中]

这是我如何使用清单和证书文件生成我的签名文件。

static void SignManifest(ZipFile zipFile, byte[] manifestFileData, X509Certificate2 certificate)
    {
        var cert = DotNetUtilities.FromX509Certificate(certificate);

        var privateKey = DotNetUtilities.GetKeyPair(certificate.PrivateKey).Private;
        var generator = new CmsSignedDataGenerator();

        generator.AddSigner(privateKey, cert, CmsSignedDataGenerator.DigestSha1);

        var certList = new System.Collections.ArrayList();
        ////////////////////////////////////////////////////////
       var a1Cert = new X509Certificate2(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwrd.cer"));
      // var a2Cert = new X509Certificate2(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AppleIncRootCertificate.cer"));
        ///////////////////////////////////////////////////////////
        certList.Add(cert);
      certList.Add(DotNetUtilities.FromX509Certificate(a1Cert));
        //certList.Add(DotNetUtilities.FromX509Certificate(a2Cert));

        Org.BouncyCastle.X509.Store.X509CollectionStoreParameters PP = new Org.BouncyCastle.X509.Store.X509CollectionStoreParameters(certList);
        Org.BouncyCastle.X509.Store.IX509Store st1 = Org.BouncyCastle.X509.Store.X509StoreFactory.Create("CERTIFICATE/COLLECTION", PP);

        generator.AddCertificates(st1);

        var content = new CmsProcessableByteArray(manifestFileData);
        var signedData = generator.Generate(content, false);

        var data = signedData.GetEncoded();

        zipFile.AddEntry("signature", data);   
    }

我可以成功生成pass.pkpass,但为什么它不在模拟器中运行?有人能告诉我原因吗?我现在真的在这里待了两天..请帮助我。

1 个答案:

答案 0 :(得分:0)