Open ueman opened 1 month ago
There's some code at which may help with it: https://github.com/tomasmcguinness/dotnet-passbook/blob/master/Passbook.Generator/PassGenerator.cs
// Pseudo Code
// This requires the user to pass a certificate with the private key included to the code as keyData
// using https://pub.dev/packages/pem
final pem = PemCodec(PemLabel.privateKey).decode(keyData);
// using pointycastle
final modulus = ASN1Object.fromBytes(pem[1]) as ASN1Integer
final exponent = ASN1Object.fromBytes(pem[3]) as ASN1Integer
final p = ASN1Object.fromBytes(pem[4]) as ASN1Integer
final q = ASN1Object.fromBytes(pem[5]) as ASN1Integer
final privateKey = RSAPrivateKey(modulus, exponent, p, q);
As a temporary solution, we could provide a callback for writing the signature. There are multiple examples for signing PKPass files with OpenSSL, and there are also OpenSSL bindings for Dart/Flutter. I however intend this library (and it's dependencies) to be Dart only.
Pseudo code example:
final pass = PkPass(...);
final pkPassFile = pass.create(signatureWriter: (contentHashes) {
// create signature here based on the contentHashes
return signature;
});
https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/PassKit_PG/YourFirst.html#//apple_ref/doc/uid/TP40012195-CH2-SW1
https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/PassKit_PG/Creating.html#//apple_ref/doc/uid/TP40012195-CH4-SW1
https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/PassKit_PG/DistributingPasses.html#//apple_ref/doc/uid/TP40012195-CH11-SW1
[ ] To create the signature file, make a
PKCS #7
detached signature of the manifest file, using the private key associated with your signing certificate. Include the WWDR intermediate certificate as part of the signature. You can download this certificate from Apple’s website. Write the signature to the file signature at the top level of the pass package. Include the date and time that the pass was signed using the S/MIME signing-time attribute.pointycastle
andpkcs7
to sign the pass in pure Dart code