Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.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#和Compact Framework 3.5中的CMS/PKCS 7签名中添加可选OID_C#_Cryptography_Openssl_Compact Framework - Fatal编程技术网

在C#和Compact Framework 3.5中的CMS/PKCS 7签名中添加可选OID

在C#和Compact Framework 3.5中的CMS/PKCS 7签名中添加可选OID,c#,cryptography,openssl,compact-framework,C#,Cryptography,Openssl,Compact Framework,通过使用CAPI函数(在C#和Compact Framework 3.5中),我尝试对XML进行签名并创建一个CMS/PKCS信封,如以下OpenSSL命令所示: openssl smime -sign -in file.xml -out file.b64 -passin pass:test -binary -nodetach -inkey cert.priv.pem -signer cert.pub.pem 通过调用函数“CryptMsgPentoencode”和“CryptMsgUpdat

通过使用CAPI函数(在C#和Compact Framework 3.5中),我尝试对XML进行签名并创建一个CMS/PKCS信封,如以下OpenSSL命令所示:

openssl smime -sign -in file.xml -out file.b64 -passin pass:test -binary -nodetach -inkey cert.priv.pem -signer cert.pub.pem
通过调用函数“CryptMsgPentoencode”和“CryptMsgUpdate”,我获得了第一个签名文件。现在,我将添加可选的OID和其他数据(更准确地说是“SMIMECapabilities”和签名时间)


怎么做?

我也有类似的问题。我找到了这篇文章,推荐使用证书注册API

Bouncy Castle还能够编写SMIMECapabilities

更新: 原始链接的内容: 据我所知,在.NET中不支持SMIMECapabilities属性,对于这个属性,证书注册API中的IX509CertificateRequestPkcs10::SMIMECapabilities似乎支持它,您可以检查一下:

其他信息: 经过一些研究,我能够使用CmsSigner编写SMIMECapabilities(我正在分离状态下创建签名文档)。 我使用这个代码

signer.SignedAttributes.Add(new AsnEncodedData("1.2.840.113549.1.9.15",  new byte[]{...})
不幸的是,CmsSigner只能将SMIMECapabilities的内容写入字节数组。我使用这个工具对openssl中创建的带有符号的文件进行解码,以找出正确的字节数组