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