drallgood / jpasskit

jPasskit is an Java™ implementation of the Apple™ PassKit Web Service.
Apache License 2.0
276 stars 109 forks source link

Generated pass not recognized in Mail app on iOS 7 #37

Closed fugu2punkt0 closed 10 years ago

fugu2punkt0 commented 10 years ago

Hi,

currently I'm having a problem with adding generated passes to the Passbook app on an iPhone. I've generated a pass and emailed it to the iPhone. When I download the atachement it displays as (null) on the phone and can't be added to the passbook app.

I'm using a PKCS#12 file and the WWDRCA.cer certificate to generate the pass. The same PKCS#12 file is used in another webservice to create demo passes. These passes are correctly recognized on the iPhone so I assume that the PKCS#12 file is valid.

For the pass I've provided the following information:

"formatVersion":1,
"serialNumber":"serial-14067964814945187177",
"passTypeIdentifier":"pass.my.demo.passbook.pass",
"authenticationToken":"0123456789abcdef",
"description":"Demo entitlement for use with Passbook",
"teamIdentifier":"<myIdentifier>",
"organizationName":"MyOrgl",
"foregroundColor":"rgb(255,255,255)",
"backgroundColor":"rgb(255,0,0)",
"labelColor":"rgb(0,0,0)",

Content of the directory: icon.png icon@2x.png logo.png logo@2x.png pass.json

manifest.json and signature are later generated and added by JPassKit.

I'm using the following code to generate the pkpass file:

try {
    PKSigningInformation signingInformation =   
        PKSigningUtil.loadSigningInformationFromPKCS12FileAndIntermediateCertificateFile(
                "./Testfiles/passbook.p12", "pswd", "./Testfiles/AppleWWDRCA.cer");
        byte[] archiveContents = PKSigningUtil.createSignedAndZippedPkPassArchive(pass, "./Testfiles/PassTemplate/", signingInformation);

        FileOutputStream fos = new FileOutputStream(new File("./Testfiles/pass.pkpass"));
        fos.write(archiveContents);
        fos.close();

        System.out.println("finished");

    } catch (UnrecoverableKeyException | NoSuchAlgorithmException
            | CertificateException | KeyStoreException
            | NoSuchProviderException | IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

I'm currently clueless why the generated pass wouldn't display on the iPhone. Thanks in advance for any help provided.

Best regards, fugu2punkt0

One thing to add: I'm developing on a Windows machine so I can't use the signpass tool!

drallgood commented 10 years ago

Do you think you could forward one of those emails to me so I can check the generated pass?

fugu2punkt0 commented 10 years ago

So the error was in the creation of the pass itself. I'd used one key twice in my pass and also provided data in the wrong format.

Thanks again to drallgood for the fast support!