assaf / node-passbook

iOS Passbook for the Node hacker
MIT License
280 stars 73 forks source link

Code=1 "Manifest signature did not verify successfully" #71

Closed FranCoulibaly closed 5 years ago

FranCoulibaly commented 5 years ago

I've been trying to figure this out for a few days now. The .pkpass appears to build correctly however, when I drag it into Simulator the following errors are logged in Console -CMS verification error: -26275 -Signature validation: FAILED -Invalid data error reading pass pass.com.example.pass/XXXXX. Manifest signature did not verify successfully -Error Domain=PKPassKitErrorDomain Code=1 "The pass cannot be read because it isn’t valid." UserInfo={NSLocalizedDescription=The pass cannot be read because it isn’t valid., NSUnderlyingError=0x60000086e6d0 {Error Domain=PKPassKitErrorDomain Code=1 "Manifest signature did not verify successfully" UserInfo={NSLocalizedDescription=Manifest signature did not verify successfully}}}.

When I unpack the .pkpass, the signature.exe file is there but it is completely empty. I can see that its loading the signing key file but then it never seems to get validated.

Code is as follows:

let template = passbook('coupon', {
   formatVersion : 1,
    passTypeIdentifier: 'pass.com.example.pass',
    teamIdentifier: 'XXXXXXX',
    webServiceURL : "https://example.com",
    authenticationToken : "1234567",
    organizationName: 'Test',
    description: 'example pass'
  });
template.loadImagesFrom('./images');
template.fields.barcode = {
      'format': 'PKBarcodeFormatPDF417',
      'message': '123456789',
      'messageEncoding':'iso-8859-1'
  };
template.fields.serialNumber = 'E5982H-I2';
template.keys('./keys', 'password');
let pass = template.createPass({
  primaryFields: [
    {
      key: "pass",
      label: "Project",
      value: "please work"
    }
  ]
});
var file = fs.createWriteStream("Callsheet.pkpass");
pass.on("error", function(error) {
  console.error(error);
  process.exit(1);
})
pass.pipe(file);
app.get("/newpass", function(request, response) {
  pass.render(response, function(error) {
  if (error)
   console.error(error);
 });

});

In the keys folder I have AppleWWDRCA.cer, Certificates.p12, com.example.pass.pem and wwdr.pem

I'm not sure if this is a bug or something I have done incorrectly (most likely the latter) but any help would be much appreciated

FranCoulibaly commented 5 years ago

I have changed the get request to this, and the signature is no longer empty however the error is still the same

app.post("/callsheet", function(request, response) {
  var file = fs.createWriteStream("callsheet.pkpass");
  pass.on("error", function(error) {
    console.error(error);
    process.exit(1);
  })
  pass.pipe(file);
   console.log("post request sent");
  pass.render(response, function(error) {
  if (error)
   console.error(error);
 });

});
FranCoulibaly commented 5 years ago

Fixed using

var signature = stdout.split(/\r\n|\n\n/)[3];

as per pull request https://github.com/assaf/node-passbook/pull/70