2014-11-21 116 views
0

我正在使用Passbook實施ios應用程序。所以我已經實現了ASP.net服務器來生成通行證。該通道從服務器端成功生成。並且當我雙擊我的mac上的pass.pkpass文件時,pass查看器顯示我從服務器創建的pass。但當我試圖將其拖到IOS模擬器時,據說「Safari瀏覽器無法下載此文件」。我已通過重新生成證書進行嘗試。但沒有任何工作。pkpass未在模擬器中顯示

這裏是我的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", 
    "[email protected]": "5afd9585b08c65fdf105a90c8bd643407cba2787", 
    "strip.png": "736d01f84cb73d06e8a9932e43076d68f19461ff", 
    "[email protected]": "468fa7bc93e6b55342b56fda09bdce7c829d7d46" 
} 

我已經出口我的通行證證書作爲P12文件和專用密鑰爲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,但爲什麼它不在模擬器中運行?有人能告訴我原因嗎?我真的在這裏呆了兩天了..請幫助我。

+0

什麼控制檯日誌告訴你嗎? – PassKit 2014-11-21 09:47:59

+0

@PassKit我還沒有嘗試從一個iOS應用程序加載它..但我知道,通過可以加載拖放到模擬器。所以我現在沒有控制檯日誌輸出.. – Darshana 2014-11-21 10:06:05

+0

當您在.pkpass包中拖動時,仍然可以打開控制檯。它應該讓你對發生的事情有所瞭解。 – PassKit 2014-11-21 10:35:40

回答

相關問題