alexandercerutti / passkit-generator

The easiest way to generate custom Apple Wallet passes in Node.js
MIT License
828 stars 104 forks source link

.pkpass not opening in iphone #79

Closed kmarrip closed 3 years ago

kmarrip commented 3 years ago

Could create a .pkpass file, that works fine in mac but the file fails to download in iphone

screen shot attached @alexandercerutti

image

const eventPass = await createPass({
      model: './Event.pass',
      certificates: {
        wwdr: './certs/wwdr.pem',
        signerCert: './certs/DerwentSignerCert.pem',
        signerKey: {
          keyFile: './certs/DerwentSignerKey.pem',
          passphrase: iosWallet.signerKeyPasword,
        },
      },
      overrides: {
        passTypeIdentifier: iosWallet.passIdentifier,
        teamIdentifier: iosWallet.teamIdentifier,
        serialNumber: eventBookingId,
      },
    });
    const stream = eventPass.generate();
    const blobName = `${eventBookingId}.pkpass`;
    const link = await sendIosWalletToBlob(stream, blobName);
    return successResponse(
      200,
      messages.iosPassLink,
      context.invocationId,
      link
    );
kmarrip commented 3 years ago

signature validation does happen even when the .pkpass is opened in mac right ??

alexandercerutti commented 3 years ago

Hey there @chaithanyaMarripati, thanks for using passkit-generator!

I currently don't know what could cause this issue, but there's one way to discover what is going on. You can follow the document I added to Wiki to debug on mac: https://github.com/alexandercerutti/passkit-generator/wiki/Self-help#through-console-mac-only

Yes, signature validation happen when it is opened. I don't know if mac has a different validation system, but it should be the same of iPhones.

Let me know what you find out!

kmarrip commented 3 years ago

Invalid data error reading pass pass.com.derwentapp/{id}. Pass dictionary must contain key 'description'.

PassBook Pass download failed: Error Domain=PKPassKitErrorDomain Code=1 "(null)"

these are the logs for passkit @alexandercerutti i already have the description key in pass.json

kmarrip commented 3 years ago
{
  "formatVersion" : 1,
  "passTypeIdentifier" : "${passtype}",
  "serialNumber" : "nmyuxofgna",
  "teamIdentifier" : "${teamId}",
  "webServiceURL" : "https://example.com/passes/",
  "authenticationToken" : "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc",
  "relevantDate" : "2011-12-08T13:00-08:00",
  "barcode" : {
    "message" : "123456789",
    "format" : "PKBarcodeFormatPDF417",
    "messageEncoding" : "iso-8859-1"
  },
  "organizationName" : "Derwent London Plc",
  "description" : "Apple Event Ticket",
  "foregroundColor" : "rgb(255, 255, 255)",
  "backgroundColor" : "rgb(60, 65, 76)",
  "eventTicket" : {
    "primaryFields" : [
      {
        "key" : "event",
        "label" : "EVENT",
        "value" : "The Beat Goes On"
      }
    ],
    "secondaryFields" : [
      {
        "key" : "loc",
        "label" : "LOCATION",
        "value" : "Moscone West"
      }
    ]
  }
}

this is the pass.json i have been using @alexandercerutti

alexandercerutti commented 3 years ago

@chaithanyaMarripati What you can do is to rename the .pkpass file to .zip, unzip it and check if the generated pass.json file has the description field or not... if it doesn't have, this might be a bug of passkit-generator...

kmarrip commented 3 years ago

@alexandercerutti i have done what you have said description is present in the pass.json file

alexandercerutti commented 3 years ago

@chaithanyaMarripati this is really weird... I've never experienced such issue. I guess that, passType and teamId are just placeholders you inserted for Github, aren't they?

kmarrip commented 3 years ago

yes, they are placeholders @alexandercerutti actual values are different

alexandercerutti commented 3 years ago

I guess you'll have to do few tests, because I sadly don't know how can I help you. You can maybe generate with different certificates.

Also, what does sendIosWalletToBlob do?

kmarrip commented 3 years ago

sendIosWalletToBlob just converts the stream to buffer and then uploads the buffer to azure blob storage giving back a unique link

alexandercerutti commented 3 years ago

Can you test with one of the examples provided within the project if you are able to generate successfully the pass? All instructions are provided within the examples folder. Clone the repo, pick one example, edit it with your data and certificates and try to download it and open it from both iPhone and Mac.

This is were we are going to exclude things in the attempt of isolating the issue.

Let me know.

kmarrip commented 3 years ago

i have overwritten the description and now im getting an altogether different error

Invalid data error reading pass pass.com.{APP_NAME}/{ID}. The passTypeIdentifier or teamIdentifier provided may not match your certificate, or the certificate trust chain could not be verified.

this is happens only in iphones, in mac i could open the .pkpass file. which makes me conclude that signature verification doesn't happen in mac at all @alexandercerutti

i may have to recheck the certificates again..

alexandercerutti commented 3 years ago

It might have different checks, but signature verification still should happen. I remember I had issues with passes on mac due to wrong certificates. Or maybe it is less strict with some checks on Mac. You could attempt to open your pass in mac with Console.app open and see which logs are printed.

Where did you overwrite the description? In the final bundle or before generating? Please note that if you overwrite it in the final bundle, you might experience issue with manifest validation.

kmarrip commented 3 years ago
const eventPass = await createPass({
      model: './Event.pass',
      certificates: {
        wwdr: './certs/wwdr.pem',
        signerCert: './certs/DerwentSignerCert.pem',
        signerKey: {
          keyFile: './certs/DerwentSignerKey.pem',
          passphrase: iosWallet.signerKeyPasword,
        },
      },
      overrides: {
        passTypeIdentifier: iosWallet.passIdentifier,
        teamIdentifier: iosWallet.teamIdentifier,
        serialNumber: eventBookingId,
        description: "this is the description for pass"
      },
    });

this is what i mean by overriding @alexandercerutti

alexandercerutti commented 3 years ago

Okay great. Let me know if by checking again the certificates you are able to fix the issue. Then, if you are able to fix the issue, you can try to remote description override and see it that happens again.

alexandercerutti commented 3 years ago

Hey there, @chaithanyaMarripati, have you been able to solve it? If so, which was the issue?

kmarrip commented 3 years ago

hey @alexandercerutti the issue wasn't with certificates Event.pass was missing event@3x.png image file, so iphones refused to open the pass while macs had no problem thanks for you help, appreciate it.

alexandercerutti commented 3 years ago

@chaithanyaMarripati that was really weird for that error! Glad you have solved!

Anyway, what is event@3x.png? Did you mean the icon@3x.png perhaps?