Closed ChurikiTenna closed 1 year ago
Hey @ChurikiTenna, do you mind sharing you pass.json?
Anyway, is the error message clear?
json is as below
var json = {
"formatVersion" : 1, // 必須。バージョン数値。
"passTypeIdentifier" : "pass.com.hoge.app", // AppleDeveloperで登録したpass名
"serialNumber" : "p69f2J", // シリアルナンバー
"teamIdentifier" : "h0GeTEsT", // AppleDeveloperで登録されたチームID
"webServiceURL" : "https://example.com/passes/", // WebサービスのURL
"authenticationToken" : "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc", // 認証トークン
"locations" : [ // 位置情報(ビーコンで使用する場合に必須)
{
"longitude" : -122.3748889, //経度
"latitude" : 37.6189722 //緯度
}
],
"barcode" : { // バーコード情報
"message" : "123456789", // 必須。バーコードと一緒に表示する文字列
"format" : "PKBarcodeFormatQR", // 必須。バーコードのフォーマットで今回はQRコードのフォーマットを指定。
"messageEncoding" : "iso-8859-1" //必須。messageのエンコーディング。
},
"organizationName" : "Organic Produce", // 必須。組織名。
"description" : "Organic Produce Loyalty Card", //必須 パスの説明。
"logoText" : "Organic Produce", // ロゴの文字列
"foregroundColor" : "rgb(255, 255, 255)", // パスの表の色
"backgroundColor" : "rgb(55, 117, 50)", // パスの背景の色
"storeCard" : {
"primaryFields" : [ //フィ-ルドデータリスト
{
"key" : "stampcard", // 文字列。パスデータ全体でユニークな値
"label" : "Stamp Card", // 文字列。表示するラベルの文字列
"value" : 21.75, // 文字列およびISO 8601形式のDateの文字列、数値。必須項目。このフィールドの値。
"currencyCode" : "USD" // 通貨単位。
}
],
"auxiliaryFields" : [ //フィ-ルドデータリスト
{
"key" : "deal", // 文字列。パスデータ全体でユニークな値
"label" : "Deal of the Day", // 文字列。表示するラベルの文字列
"value" : "Lemons" // 文字列およびISO 8601形式のDateの文字列、数値。必須項目。このフィールドの値。
}
]
}
}
Previous error message (TypeError) was resolved. But now I get 'Invalid PEM formatted message'.
I didn't notice it immediately... but why are you passing the paths to certificates properties?
Ok. I was supposed to pass Buffer of each pem file... I changed the code.
var wwdr = await getRawBody(storage.file('AppleWWDRCA.pem').createReadStream());
var signerCert = await getRawBody(storage.file('pass.pem').createReadStream());
var signerKey = await getRawBody(storage.file('distribution.pem').createReadStream());
Now I get this error.
Error: Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".
I don't know what getRawBody
does. Also, are you using Firebase Storage API? I never used it.
Try printing the values of wwdr
, signerCert
and signerKey
. You should be able to see the same values as your local files.
getRawBody
gets buffer of a stream as a Buffer.
With console.log("wwdr",wwdr)
, log was like this.
wwdr <Buffer 2d 2d 2d 2d 2d 42 45 47 49 4e 20 43 45 52 54 49 46 49 43 41 54 45 2d 2d 2d 2d 2d 0a 4d 49 49 45 49 6a 43 43 41 77 71 67 41 77 49 42 41 67 49 49 41 64 ... 1443 more bytes>
With console.log("wwdr",wwdr.toString())
, log was like this.
wwdr -----BEGIN CERTIFICATE-----
MIIEIjCCAwqgAwIBAgIIAd68xDltoBAwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UE
....
sj+5ZSxN9hhaqiydT6ul5JbaxkQ6byiYgb7/4WnHx2LFY3fwl34gTXF+aG/DaUSC
-----END CERTIFICATE-----
@ChurikiTenna what about the signerKey and the signerCert? The error message seems to report an error on those two? Do you see differences?
The signerKey and the signerCert produce similar log.
signerCert -----BEGIN CERTIFICATE-----
MIIGLDCCBRSgAwIBAgIQEEhbD66wCZhNhfEc9RYlCTANBgkqhkiG9w0BAQsFADB1
....
sj+5ZSxN9hhaqiydT6ul5JbaxkQ6byiYgb7/4WnHx2LFY3fwl34gTXF+aG/DaUSC
-----END CERTIFICATE-----
signerKey -----BEGIN CERTIFICATE-----
MIIFyTCCBLGgAwIBAgIQY6x4HmjouT9qbRR3HGUf/jANBgkqhkiG9w0BAQsFADB1
....
nEYRGEISW42cj6IWl+2Znp2pDyKnNluesyqMzlY/UGHpP2njicCyOTOh1Nb5
-----END CERTIFICATE-----
There's something wrong here: my signerCert.pem
and signerKey.pem
have some metadata before. Also signerKey.pem
starts with a different header. Are you sure you converted the files correctly? Which procedure did you follow?
I see something like this:
I was not following this guide, and was generating .pem file directory from .cert file. https://github.com/alexandercerutti/passkit-generator/wiki/Generating-Certificates
Tried creating .pem file according to the instruction, and now it works!!! Thank you so much for your kindest support!
What guide / command were you following, just to understand?
I didn't find the correct guideline first, and had no ideas what I was doing. I think I did something like this to create pem file.
openssl x509 -in ios_distribution.cer -inform DER -out ios_distribution.pem -outform PEM
Running OS
iOS
Running Node Version
18.0.0
Description
const buffer = pass.getAsBuffer();
throws errorCode:
Expected behavior
Be able to get buffer.
Steps to reproduce
Run the code above.
Were you able to verify it by using (and changing) the examples?
Yes
If yes, which changes did you apply?
Deleted pass.strings section. Added my wwdr, signerCert, signerKey, signerKeyPassphrase. Deleted pass.localize("en", {});
Other details