drallgood / jpasskit

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

cannot open created .pkpass with valid certs when using PKFileBasedSigningUtil #100

Closed jonniedarko closed 6 years ago

jonniedarko commented 6 years ago

I generate the pk pass as follows:

PKSigningInformation pkSigningInformation = new  PKSigningInformationUtil()
                .loadSigningInformationFromPKCS12AndIntermediateCertificate(
                "/path/to/pass.p12",
                "password",
                "/path/to/pass/wwdr.pem"
        );

PKFileBasedSigningUtil pkSigningUtil = new PKFileBasedSigningUtil();
String tempPath = "/tmp/mypass.raw";
PKPassTemplateFolder   passTemplate        = new PKPassTemplateFolder(tempPath);
byte[] signedAndZippedPkPassArchive = pkSigningUtil.createSignedAndZippedPkPassArchive(pass, passTemplate, pkSigningInformation);
ByteArrayInputStream inputStream = new ByteArrayInputStream(signedAndZippedPkPassArchive);
String fileName = "/tmp/pass.pkpass";
File passZipFile = new File(fileName);
IOUtils.copy(inputStream, new FileOutputStream(passZipFile));

but I can't open the resulting .pkpass. It is not a certificate issue because I can use the same pass.p12, password, and wwdr.pem to create a .pkpass in PHP using this library and I can unzip and everything is generated fine. I can only guess it is a signature issue but I cannot understand why

jonniedarko commented 6 years ago

It does work when using PKInMemorySigningUtil so maybe I'm doing something wrong with how I create the zip?

drallgood commented 6 years ago

Hi @jonniedarko Not sure exactly what's going on. Did you try to check the created pass with the signpass util? https://developer.apple.com/services-account/download?path=/iOS/Wallet_Support_Materials/WalletCompanionFiles.zip

If you like, I can also have a look. All I need is the generated pass.

jonniedarko commented 6 years ago

So I was able to verify the pass created with PKInMemorySigningUtil using the preview on mac but not with the PKFileBasedSigningUtil. Its not a blocker for me as I can just use the PKInMemorySigningUtil, Just thought I should raise the issue for clarity.

drallgood commented 6 years ago

Yeah. This sounds like a bug I would like to squash (if it is one) The tests I have so far didn't uncover any issues, so I'd really appreciate your help with figuring out what's going on

jonniedarko commented 6 years ago

​Let me know what I can do to help​

onlyamir007 commented 6 years ago

hi guys,

im having same issue im able to create .pkpass im able unzip also but iphone don't understand not able to open

DerekFangming commented 6 years ago

I'm having the exact same issue. However, mine happens after updating my cert file since it expired last month. Now the pkpass file is still generated but I can no longer open it. Any movements on this issue?

@drallgood If you are looking for samples, here you go. The pass named working.pkpass was generated before my cert expired. If you check that out, it's certificate had expired but you can open it with ios devices. The notWorking.pkpass was generated today after I switch to a renewed certificate. Now the cert is not expired but I can not open the pass anymore.

Any help is greatly appreciated! I'm using version 0.1.0

drallgood commented 6 years ago

@DerekFangming The answer is pretty simple in your case: Working:

$ ./signpass  -v working.pkpass 
Signature valid.
Certificates: (
    0: Apple Worldwide Developer Relations Certification Authority
    1: Pass Type ID: pass.com.fmning.WPI-CSA
)
Trust chain is valid.

*** SUCCEEDED ***

Not working:

$ ./signpass  -v notWorking.pkpass 
Pass is missing files listed in the manifest, {
    "._.DS_Store" = 5ab2bf7809050d011ea3edf4466af77fedb26112;
    "._en.lproj" = e7544378ba46326fdd35efaa875e443bdd4e5ae2;
    "._icon.png" = 70a792abf8ea933fd94d7228307a28d2ffc99731;
    "._icon@2x.png" = c28e0c0f334bd48534e26c615dfd1508d532acee;
    "._logo.png" = c28e0c0f334bd48534e26c615dfd1508d532acee;
    "._logo@2x.png" = c28e0c0f334bd48534e26c615dfd1508d532acee;
    "en.lproj/._.DS_Store" = 5ab2bf7809050d011ea3edf4466af77fedb26112;
}

*** FAILED ***
drallgood commented 6 years ago

Looks like it's including a bunch of dot files

DerekFangming commented 6 years ago

@drallgood Bluhhh realllllly????? Let me double check that but im banging my head on my desk right now lol

Thanks for the info!

drallgood commented 6 years ago

@DerekFangming Question is why those files would be in the manifest but not the zip file. I looked at the code, but can't explain it yet.

DerekFangming commented 6 years ago

@drallgood I did not change my code and it just failed. I'll have a look at your end to see what I can do. I'll make a PR if I find out why & fix it.

drallgood commented 6 years ago

@DerekFangming That would be great. Thanks!

The logic for creating the manifest and zipping is almost identical. So if it adds a file to the manifest it should also add it to the zip (unless someone deletes it from the temp folder in the mean time)