Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

certificate - Adding signingCertificateV2 attribute to SignedCms

    ContentInfo content = new ContentInfo(new Oid("1.2.840.113549.1.7.5"), Encoding.UTF8.GetBytes(str.ToString()));
    
    SignedCms signedCms = new SignedCms(content, true);
    CmsSigner cmsSigner = new CmsSigner(cert);

    cmsSigner.IncludeOption = X509IncludeOption.EndCertOnly;
    cmsSigner.DigestAlgorithm = new Oid("2.16.840.1.101.3.4.2.1");
    cmsSigner.SignerIdentifierType = SubjectIdentifierType.IssuerAndSerialNumber;


    Pkcs9AttributeObject att = new Pkcs9AttributeObject();
    AsnEncodedData data = new AsnEncodedData(new SHA1Managed().ComputeHash(cert.RawData));

    cmsSigner.SignedAttributes.Add(new Pkcs9SigningTime(DateTime.UtcNow));
    //cmsSigner.SignedAttributes.Add(new Pkcs9ContentType());
    //cmsSigner.SignedAttributes.Add(new Pkcs9MessageDigest());
   
    signedCms.ComputeSignature(cmsSigner);
    return Convert.ToBase64String(signedCms.Encode());

I have used this code to sign a document and this code is working fine but my problem is that there is another requirement needed to add "SigningCertificateV2" attribute as a signed attribute...

I have already added ContentType, MessageDigest and SigningTime. But i dont know how to add "SigningCertificateV2" attribute.. (1.2.840.113549.1.9.16.2.47)

Can You please help me with this?

question from:https://stackoverflow.com/questions/65914439/adding-signingcertificatev2-attribute-to-signedcms

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...