Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.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
在VB.net中创建和验证PKCS#7签名_Vb.net_Pkcs#7 - Fatal编程技术网

在VB.net中创建和验证PKCS#7签名

在VB.net中创建和验证PKCS#7签名,vb.net,pkcs#7,Vb.net,Pkcs#7,我想知道如何在VB.net中生成和验证PKCS#7签名。这些签名需要存储在一个单独的文件中,与它们正在验证的数据(例如test.dat和test.dat.sig)相对应。我在另一个问题中找到了生成签名的代码,但不知道如何验证它们 Public Sub SignFile(ByVal theFilename As String, ByVal theCertFile As String, ByVal thePassword As String, ByVal theDestination As Stri

我想知道如何在VB.net中生成和验证PKCS#7签名。这些签名需要存储在一个单独的文件中,与它们正在验证的数据(例如test.dat和test.dat.sig)相对应。我在另一个问题中找到了生成签名的代码,但不知道如何验证它们

Public Sub SignFile(ByVal theFilename As String, ByVal theCertFile As String, ByVal thePassword As String, ByVal theDestination As String)
    Dim aCertificate = New X509Certificates.X509Certificate2(theCertFile, thePassword)
    Dim aByteArray = IO.File.ReadAllBytes(theFilename)
    Dim anOid = New System.Security.Cryptography.Oid("1.2.840.113549.1.7.2")
    Dim aContentInfo = New Pkcs.ContentInfo(anOid, aByteArray)
    Dim aSignedCms = New Pkcs.SignedCms(aContentInfo, True)
    Dim aCmsSigner = New Pkcs.CmsSigner(Pkcs.SubjectIdentifierType.IssuerAndSerialNumber, aCertificate)

    aSignedCms.ComputeSignature(aCmsSigner)
    Dim aSignature = Convert.ToBase64String(aSignedCms.Encode())
    IO.File.WriteAllText(theDestination, aSignature)
End Sub

感谢

以下内容可能会帮助您验证CMS/PKCS#7签名