【问题标题】:Signing and Email - Cannot find the original signer签名和电子邮件 - 找不到原始签名者
【发布时间】:2012-05-30 00:42:45
【问题描述】:

我有以下代码,但是当我运行代码时收到错误 System.Security.Cryptography.CryptographicException: 找不到原始签名者。, 为什么会这样?是不是因为我的证书设置不正确?

    public byte[] GetSignature(string message, X509Certificate2 signingCertificate,
                               X509Certificate2 encryptionCertificate)
    {
        byte[] messageBytes = Encoding.ASCII.GetBytes(message);

        SignedCms signedCms = new SignedCms(new ContentInfo(messageBytes), true);

        CmsSigner cmsSigner = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, signingCertificate);
        cmsSigner.IncludeOption = X509IncludeOption.WholeChain;

        if (encryptionCertificate != null)
        {
            cmsSigner.Certificates.Add(encryptionCertificate);
        }

        Pkcs9SigningTime signingTime = new Pkcs9SigningTime();
        cmsSigner.SignedAttributes.Add(signingTime);

        signedCms.ComputeSignature(cmsSigner, false);

        return signedCms.Encode();
    }

【问题讨论】:

    标签: .net x509certificate


    【解决方案1】:

    您是否尝试过删除此行:

    cmsSigner.IncludeOption = X509IncludeOption.WholeChain;
    

    我遇到了与您描述的相同的问题,我也使用了WholeChain 选项,省略它为我解决了问题。即使这个问题是 8 个月前发布的,我希望它会对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多