C# 在c中为apple passbook签名内容#
这是我的密码C# 在c中为apple passbook签名内容#,c#,passbook,C#,Passbook,这是我的密码 static void Main(string[] args) { try { ContentInfo contentInfo = new ContentInfo(File.ReadAllBytes(@"D:\prj\temp\manifest.json")); SignedCms signedCms = new SignedCms(SubjectIdentifierType.IssuerAnd
static void Main(string[] args)
{
try
{
ContentInfo contentInfo = new ContentInfo(File.ReadAllBytes(@"D:\prj\temp\manifest.json"));
SignedCms signedCms = new SignedCms(SubjectIdentifierType.IssuerAndSerialNumber, contentInfo);
var signer = new CmsSigner(new X509Certificate2(@"D:\prj\temp\Shooger_Passbook_withoutKey.p12", "xxxxxxxxx"));
signer.Certificates.Add(new X509Certificate2(@"D:\prj\temp\AppleIncRootCertificate.cer"));
signer.Certificates.Add(new X509Certificate2(@"D:\prj\temp\AppleWWDRCA.cer"));
signer.IncludeOption = X509IncludeOption.WholeChain;
signer.SignedAttributes.Add(new Pkcs9SigningTime());
signedCms.ComputeSignature(signer, false);
byte[] myCmsMessage = signedCms.Encode();
File.WriteAllBytes(@"D:\prj\temp\signature", myCmsMessage);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
有人能告诉我为什么它抛出“发生内部证书链接错误”吗?尝试从Windows证书存储加载证书 下面的链接将为您提供在.net中签名通行证的详细教程
希望这有帮助:) 我为.Net创建了一个OSS库,可以为您处理所有这些。您只需要自己的存折证书和主苹果证书
对于那些在续订证书后发现证书不起作用的人,现在需要在签名中添加“已签名时间”属性。因此:
var oid = new Oid("1.2.840.113549.1.7.2");
ContentInfo contentInfo = new ContentInfo(oid, manifest);
var signedCms = new SignedCms(contentInfo, true);
var signer = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, myX509certificate);
signer.IncludeOption = X509IncludeOption.EndCertOnly;
signer.Certificates.Add(appleWwdrCertificate);
// new requirement to add 'signing-date'
signer.SignedAttributes.Add(new Pkcs9SigningTime(DateTime.Now));
signedCms.ComputeSignature(signer);
bytes[] signature = signedCms.Encode();