alexandercerutti / passkit-generator

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

Invalid certificate(s) loaded error on seemingly valid input #148

Closed dev-sda1 closed 1 year ago

dev-sda1 commented 1 year ago

Running OS

macOS 13

Running Node Version

v.18.16.1

Description

Followed all the steps in the wiki to correctly generate certificates, and referenced the examples to correctly read the certificates when creating a pass, however it throws a [Error [ValidationError]: "wwdr" is required]. The validation check in PKPass.js indicate that the passed through certificate needs to be a string, however it is exactly that. Writing the WWDR certificate out to console in both the example and my own yield the exact same result, so I'm not too sure what's happening here.

Screenshot 2023-06-25 at 19 09 48

Expected behavior

To read the certificate strings, and generate the pass.

Full code:

const pass = new PKPass({
        model: "./passContent/Lollipop.pass",
        certificates: {
            wwdr: certificates.wwdr,
            signerCert: certificates.signerCert,
            signerKey: certificates.signerKey,
            signerKeyPassphrase: certificates.signerKeyPassphrase
        },
    },{
        serialNumber: "123456",
    });
    const [signerCert, signerKey, wwdr, signerKeyPassphrase] = await Promise.all([
        fs.readFile(path.resolve(process.cwd(), "./app/certs/signerCert.pem"), "utf-8"),
        fs.readFile(path.resolve(process.cwd(), "./app/certs/signerKey.pem"), "utf-8"),
        fs.readFile(path.resolve(process.cwd(), "./app/certs/wwdr.pem"), "utf-8"),
        Promise.resolve("tyfoon63%")
    ]);

Were you able to verify it by using (and changing) the examples?

No.

Other details

alexandercerutti commented 1 year ago

Hey there @dev-sda1, thanks for using passkit-generator.

I guess you misread the API documentation: model is supported only by PKPass.from. I guess that's the issue. I tried to keep the API similar (new PKPass vs PKPass.from), but they are different.

I suggest you read the documentation again and try with PKPass.from if you want to read a model.

Let me know!

dev-sda1 commented 1 year ago

Yep, turns out that was the issue, thanks!