无法使用Dotnet-PassBook v3.0.2打开服务器中创建的PassKit文件
最近,我遇到了一个问题,即我无法打开使用Dotnet-Passbook版本3.2.0创建的PKPass。
可以很好地打开本地创建的PKPass,并且问题是服务器中创建的PKPass。
我什至尝试将PKPass从服务器上传到验证器,但是 valivator 只是返回“返回”未能返回“未能流程”处理。 pkpass文件。”
以下是我用于构建PKPASS的代码快照:
public static FileContentResult GetPass(Shopper account)
{
try {
if (account == null)
{
return null;
}
PassGenerator generator = new PassGenerator();
PassGeneratorRequest request = new PassGeneratorRequest();
// "webServiceURL" : "https://example.com/passes/",
// "authenticationToken" : "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc",
// Product info
request.PassTypeIdentifier = "PassTypeIdentifier";
request.TeamIdentifier = "TeamIdentifier";
request.SerialNumber = "SerialNumber";
request.Description = "Description";
request.OrganizationName = "OrganizationName";
request.LogoText = "LogoText";
// Add the installed certificate and it's thumbprint
WebClient webClient = new WebClient();
try
{
X509KeyStorageFlags flags = X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable;
request.PassbookCertificate = new X509Certificate2(webClient.DownloadData(CertificatesBucket + "/Certificates.p12"), S3_AppleCertificatePassword, flags);
}
catch (Exception e)
{
throw new Exception("Error occurs when geting certificate: " + e.Message);
}
// Add Apple's WWDRCA certificates
try
{
request.AppleWWDRCACertificate = new X509Certificate2(webClient.DownloadData(CertificatesBucket + "/AppleWWDRCAG2.cer"));
}
catch (Exception e)
{
throw new Exception("Error occurs when geting AppleWWDRCCA: " + e.Message);
}
// override icon and icon retina
try
{
request.Images.Add(PassbookImage.Logo, webClient.DownloadData(AppleImageBucket + "/logo.png"));
request.Images.Add(PassbookImage.Icon, webClient.DownloadData(AppleImageBucket + "/icon.png"));
request.Images.Add(PassbookImage.Icon2X, webClient.DownloadData(AppleImageBucket + "/icon%402x.png"));
request.Images.Add(PassbookImage.Strip, webClient.DownloadData(AppleImageBucket + "/strip.png"));
request.Images.Add(PassbookImage.Strip2X, webClient.DownloadData(AppleImageBucket + "/strip%402x.png"));
}
catch (Exception e)
{
throw new Exception("Error occurs when geting images: " + e.Message);
}
// Add barcode
request.AddBarcode(BarcodeType.PKBarcodeFormatCode128, account.Id, "ISO-8859-1");
// Link the pass to an existing app using the app's Apple ID.
request.AssociatedStoreIdentifiers.Add(121212);
request.Style = PassStyle.StoreCard;
// Add fields
request.AddHeaderField(new StandardField("StandardField", "TEXT", account.Id));
request.AddSecondaryField(new StandardField("StandardField", "TEXT", account.Name));
request.AddSecondaryField(new StandardField("StandardField", "TEXT", "TEXT"));
request.TransitType = TransitType.PKTransitTypeAir;
byte[] generatedPass = generator.Generate(request);
//throw new Exception("apple generatedPass: " + JsonTransHelper.SerializeObject(generatedPass));
return new FileContentResult(generatedPass, "application/vnd.apple.pkpass");
}
catch (Exception ex)
{
throw new Exception("Error occurs when creating apple pass: " + ex.Message);
}
}
}
}
任何帮助都非常感谢!
I have recently come across an issue that I cannot open my Pkpass which is created using dotnet-passbook version 3.2.0.
The Pkpass created locally can be opened fine and the issue is with the Pkpass created in the server.
I have even tried to upload the Pkpass from the server to the validator but the validator just returns “Failed to process the Pkpass file.”
Below is my code snapshot for building the Pkpass:
public static FileContentResult GetPass(Shopper account)
{
try {
if (account == null)
{
return null;
}
PassGenerator generator = new PassGenerator();
PassGeneratorRequest request = new PassGeneratorRequest();
// "webServiceURL" : "https://example.com/passes/",
// "authenticationToken" : "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc",
// Product info
request.PassTypeIdentifier = "PassTypeIdentifier";
request.TeamIdentifier = "TeamIdentifier";
request.SerialNumber = "SerialNumber";
request.Description = "Description";
request.OrganizationName = "OrganizationName";
request.LogoText = "LogoText";
// Add the installed certificate and it's thumbprint
WebClient webClient = new WebClient();
try
{
X509KeyStorageFlags flags = X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable;
request.PassbookCertificate = new X509Certificate2(webClient.DownloadData(CertificatesBucket + "/Certificates.p12"), S3_AppleCertificatePassword, flags);
}
catch (Exception e)
{
throw new Exception("Error occurs when geting certificate: " + e.Message);
}
// Add Apple's WWDRCA certificates
try
{
request.AppleWWDRCACertificate = new X509Certificate2(webClient.DownloadData(CertificatesBucket + "/AppleWWDRCAG2.cer"));
}
catch (Exception e)
{
throw new Exception("Error occurs when geting AppleWWDRCCA: " + e.Message);
}
// override icon and icon retina
try
{
request.Images.Add(PassbookImage.Logo, webClient.DownloadData(AppleImageBucket + "/logo.png"));
request.Images.Add(PassbookImage.Icon, webClient.DownloadData(AppleImageBucket + "/icon.png"));
request.Images.Add(PassbookImage.Icon2X, webClient.DownloadData(AppleImageBucket + "/icon%402x.png"));
request.Images.Add(PassbookImage.Strip, webClient.DownloadData(AppleImageBucket + "/strip.png"));
request.Images.Add(PassbookImage.Strip2X, webClient.DownloadData(AppleImageBucket + "/strip%402x.png"));
}
catch (Exception e)
{
throw new Exception("Error occurs when geting images: " + e.Message);
}
// Add barcode
request.AddBarcode(BarcodeType.PKBarcodeFormatCode128, account.Id, "ISO-8859-1");
// Link the pass to an existing app using the app's Apple ID.
request.AssociatedStoreIdentifiers.Add(121212);
request.Style = PassStyle.StoreCard;
// Add fields
request.AddHeaderField(new StandardField("StandardField", "TEXT", account.Id));
request.AddSecondaryField(new StandardField("StandardField", "TEXT", account.Name));
request.AddSecondaryField(new StandardField("StandardField", "TEXT", "TEXT"));
request.TransitType = TransitType.PKTransitTypeAir;
byte[] generatedPass = generator.Generate(request);
//throw new Exception("apple generatedPass: " + JsonTransHelper.SerializeObject(generatedPass));
return new FileContentResult(generatedPass, "application/vnd.apple.pkpass");
}
catch (Exception ex)
{
throw new Exception("Error occurs when creating apple pass: " + ex.Message);
}
}
}
}
Any help greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它是由AWS API网关引起的。如果您在lambda函数上运行此操作,请尝试直接调用它。
无法在中央目录中保留INT64 .NET核心
It is caused by AWS API Gateway. If you running this on a Lambda function try to invoke it directly.
Offset to Central Directory cannot be held in an Int64 .net core