tomasmcguinness / dotnet-passbook

A .Net Library for generating Apple Passbook (Wallet) files for iOS. Please get involved by creating pull requests and opening issues!
MIT License
319 stars 117 forks source link

Unable to open pkpass on an iOS device #41

Closed VyasRR closed 8 years ago

VyasRR commented 8 years ago

Hi,

I am able to generate a .pkpass file using C# code (thanks to the tutorials available). The pass which I generated works correct on Android device(installed an application Pass2U Wallet to open the pass) and MAC OS (through mail).

But, the same pass does not open on an iOS device. There isn't any error message that pops up when I try to open the pass from the iPhone. It simply does not open up (it is probably treating the attachment as unrecognized file).

Kindly help me.

I have also attached the generated pkpass file for reference.

Regards, Vyas

IndyCar.zip

joe-keane commented 8 years ago

Hi,

Seems like you have to fix passTypeIdentifier and set it with the same id that you did configure Developer portal. Also you're setting the webServiceURL to an Apple URL http://ocsp.apple.com/ocsp3-wwdr01

VyasRR commented 8 years ago

Hi Joe,

I have changed the passTypeIdentifier but still I am facing the same problem. This time I removed the webServiceURL because I dont require my pass to hit any URL (also, I read in many blogs saying that webServiceURL and authenticationToken is not mandatory).

Attaching my new pkpass again.

IndyCar.zip

joe-keane commented 8 years ago

Hi Vyas, The fields must be unique, you've several of them called "date".

VyasRR commented 8 years ago

Thank you so much. Your answer resolved my issue.

But while I try to deploy the code on IIS server, I am getting a weird error "The recipient certificate is not specified".

joe-keane commented 8 years ago

Hi Vyas,

I'm glad I did help.

Around the new error I'm sure if it's passbook related or something with certificates. Can you provide more context around the message?

VyasRR commented 8 years ago

I deployed my website in the IIS present on Windows 2012 R2 machine. While the code hits the ComputeSignature line, I am facing the error "The recipient certificate is not specified".

The code runs perfectly on visual studio and the problem i am facing is only with the deployed code.

Below is the piece of code I am using for computing signature against the manifest:

private byte[] signit(string manifest, X509Certificate2 ourcert)
        {           
                byte[] manifestbytes = ASCIIEncoding.ASCII.GetBytes(manifest);

                ContentInfo contentinfo = new ContentInfo(manifestbytes);
                SignedCms signedcms = new SignedCms(contentinfo, true);

                X509Certificate2 appleWWDRCA = new X509Certificate2(currentDirectory + @"AppleCerts\Apple Worldwide Developer Relations Certification Authority.cer");

                CmsSigner oursigner = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, ourcert);
                //CmsSigner oursigner = new CmsSigner(ourcert);
                oursigner.IncludeOption = X509IncludeOption.EndCertOnly;

                oursigner.Certificates.Add(appleWWDRCA);

                oursigner.SignedAttributes.Add(new Pkcs9SigningTime(DateTime.Now));

                signedcms.ComputeSignature(oursigner);
                return signedcms.Encode();           
        }
joe-keane commented 8 years ago

I'm not entirely sure about it, but could be permissions or certificates related otherwise it won't run also on your machine. Do you want to create a small sample with it?

tomekdomek commented 8 years ago

Hi, I am running the same issue that I cant open the passes on Iphone but on MAc it works fine. I looked on every thing which was written here but it just dont open.

joe-keane commented 8 years ago

Hi @tomekdomek, did you check the logs while opening? Can you provide a sample file?

tomekdomek commented 8 years ago

Here you go.Thank you. I made the pass without Can upload the file. I uloaded it on my server. www.pbooking.de/passbook.zip

joe-keane commented 8 years ago

Here you go: ": Invalid data error reading pass pass.cbooking.de/4efc0224-c134-4b48-a27e-9cb63dcb57f1. Unable to parse relevantDate 2016-04-08T09:16:45.0789286+02:00 as a date. We expect dates in "W3C date time stamp format", either "Complete date plus hours and minutes" or "Complete date plus hours, minutes and seconds". For example, 1980-05-07T10:30-05:00."

If you plug the device to your mac the Devices logger will show you what's going on.

tomekdomek commented 8 years ago

Oh ok thanks. You recommand XCode for that.

So I guess the codebase is wrong because I set it by property of class PassGeneratorRequest and he rechanges it to that format.

joe-keane commented 8 years ago

You're right, the issue was introduced with this change: writer.WriteValue(RelevantDate.Value.ToString("o")); Will need to take a look into a proper fix.

tomekdomek commented 8 years ago

Can you give me the line how it should be so I can change it? Ok I got writer.WriteValue(RelevantDate.Value.ToString("yyyy-MM-ddTHH:mm:sszzz"));​

joe-keane commented 8 years ago

@tomasmcguinness I'm planing to take a look into it today regarding the comments from @tuler at #45 and #46

janaridev commented 4 months ago

@joe-keane Hi ! this question was asked 8 years ago, but you are one of the people who know pkpasses very well, if you are still coding, please can you help me

i am trying to generate pkpass, and i am generating it, but when i try to open it with my iphone, nothing happens

test.zip

when i am validating it in https://pkpassvalidator.azurewebsites.net/, it says that all is ok, here is an image Screenshot from 2024-07-13 15-58-27

joe-keane commented 4 months ago

@janaridev you need to check a few more bits which the tool doesn't do. Icon size is one of them -- 29x29 · 58x58 (@2x). https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/PassKit_PG/Creating.html