Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 签署和创建asn1 signedmessage-Bouncycastle_C#_Bouncycastle_Asn.1_Pkcs#7 - Fatal编程技术网

C# 签署和创建asn1 signedmessage-Bouncycastle

C# 签署和创建asn1 signedmessage-Bouncycastle,c#,bouncycastle,asn.1,pkcs#7,C#,Bouncycastle,Asn.1,Pkcs#7,有没有关于如何使用bouncycastle对文件进行签名并将其封装在asn1 pkcs7包中的好教程?过了一段时间,我在bouncycastle应用程序中的示例中找到了如何进行签名的方法 它实际上比我在IText中发现的更简单、更直接(没有去掉框架本身的友好性) 代码类似于: AsymmetricCipherKeyPair signaturePair; X509Certificate signatureCert; IList certList =

有没有关于如何使用bouncycastle对文件进行签名并将其封装在asn1 pkcs7包中的好教程?

过了一段时间,我在bouncycastle应用程序中的示例中找到了如何进行签名的方法

它实际上比我在IText中发现的更简单、更直接(没有去掉框架本身的友好性)

代码类似于:

        AsymmetricCipherKeyPair signaturePair;
        X509Certificate signatureCert;

        IList certList = new ArrayList();
        IList crlList = new ArrayList();
        CmsProcessable msg = new CmsProcessableByteArray(Encoding.ASCII.GetBytes("I hate hello world!"));

        certList.Add(signatureCert);
        certList.Add(OrigCert);

        crlList.Add(SignCrl);

        IX509Store x509Certs = X509StoreFactory.Create(
            "Certificate/Collection",
            new X509CollectionStoreParameters(certList));
        IX509Store x509Crls = X509StoreFactory.Create(
            "CRL/Collection",
            new X509CollectionStoreParameters(crlList));

        CmsSignedDataGenerator gen = new CmsSignedDataGenerator();

        gen.AddSigner(signaturePair.Private, signatureCert, CmsSignedDataGenerator.DigestSha1);

        gen.AddCertificates(x509Certs);
        gen.AddCrls(x509Crls);

        CmsSignedData signedData = gen.Generate(msg, true);

        //saving in BER encoding
        Stream stream = new MemoryStream(signedData.GetEncoded());