好吧,我们都知道,苹果公司的 news release 说,苹果公司的 WWDR 证书在情人节那天已经过期(这就是我所说的“开发者之爱”)。
我正在使用 C# 为 Safari 生成推送包,而且令人惊讶的是,这不再起作用。这是我在日志记录端点中收到的消息:
这是我旧的 PKCS#7 签名代码的样子:
// Sign the message with the private key of the signer.
static byte[] PKCS7SignMessage(byte[] message, X509Certificate2 signerCertificate)
{
// Place message in a ContentInfo object.
// This is required to build a SignedCms object.
ContentInfo contentInfo = new ContentInfo(message);
// Instantiate SignedCms object with the ContentInfo above.
// Has default SubjectIdentifierType IssuerAndSerialNumber.
// Has default Detached property value false, so message is
// included in the encoded SignedCms.
SignedCms signedCms = new SignedCms(contentInfo, true);
// Formulate a CmsSigner object for the signer.
CmsSigner cmsSigner = new CmsSigner(signerCertificate);
cmsSigner.IncludeOption = X509IncludeOption.EndCertOnly;
// Sign the CMS/PKCS #7 message.
signedCms.ComputeSignature(cmsSigner);
// Encode the CMS/PKCS #7 message.
return signedCms.Encode();
}
Apple 还要求“将路径传递到额外证书参数的更新中间体”。所以我试过这个:
X509Certificate2 appleIntermediate = new X509Certificate2();
appleIntermediate.Import(@"Path-to-new-WWRD.cer");
cmsSigner.Certificates.Add(appleIntermediate);
没用。 (推送包签名验证失败)后来我试图改变这一行:
cmsSigner.IncludeOption = X509IncludeOption.WholeChain;
没用。 我有一个异常(exception)说:好吧,现在我决定:
但是:它没有用。 (推送包签名验证失败)
根据 Apple 的说法,解决这个问题是小菜一碟:
现在,这在英语计划中意味着什么?
以及如何将其应用于 C# 上下文?
最佳答案
苹果不想要整个链条。他们只希望包含您的证书和他们的中级证书。所以你的代码应该是这样的:
static public byte[] PKCS7SignMessage(byte[] manifest_data, X509Certificate2 signerCertificate) {
X509Certificate2Collection ca_chain;
ContentInfo content;
SignedCms signed_cms;
CmsSigner signer;
signed_cms = new SignedCms();
ca_chain = new X509Certificate2Collection(new X509Certificate2(@"Path-to-new-intermediate-WWRD.cer"));
content = new ContentInfo(manifest_data);
signed_cms = new SignedCms(content, true);
signer = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, signerCertificate);
signer.IncludeOption = X509IncludeOption.ExcludeRoot;
signer.Certificates.AddRange(ca_chain);
signed_cms.ComputeSignature(signer);
return signed_cms.Encode();
}
关于c# - Safari 推送包 : how to fix Apple's expired WWDR certificate,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35574470/