There exist several ways to sign XML documents, depending on the underlying standards which need to be employed. The extension you referenced (p7m) implies that the files are expected to be signed with PKCS#7/CMS method, yet at the same time XML specification provides for its own, independent, signature standard (XML-SIG). In order to achieve interoperability with third-party verifiers it is important to establish the exact format the receiving party expects the documents to be signed in.

At first glance the approach explained down the above link will work for you (as it basically will allow you to create p7m signatures), but we will be able to give you a more accurate answer if you share with us a link to the verifier requirements or a sample signed document.

Using msSave As MemoryStream = New MemoryStream()
CMSMessage.Save(msSave)
Using fileStr As FileStream = New FileStream(outfile, FileMode.Create, FileAccess.Write)
Dim bytes As Byte() = New Byte(msSave.Length - 1) {}
msSave.Read(bytes, 0, CInt(msSave.Length))
fileStr.Write(bytes, 0, bytes.Length)
msSave.Close()
End Using
End Using
fs.close()
End Using

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.