Discuss this help topic in SecureBlackbox Forum
Load CMS message
In SecureBlackbox, signed CMS messages are handled by the TElSignedCMSMessage class.
To load an existing signed message, create a stream over it, and pass this stream to the TElSignedCMSMessage.Open() method. The following code snippet explains how to load a CMS message from file:
TElSignedCMSMessage msg = new TElSignedCMSMessage();
FileStream f = new FileStream("message.p7s", FileMode.Open);
try
{
msg.Open(f, null);
}
finally
{
f.Close();
}
Note the 'null' value passed as a parameter to the Open() call.
The second parameter expects the stream containing the message data for detached signatures (i.e., the signatures that are kept aside the signed data).
In the above code we are passing 'null' to indicate that the data is contained in the CMS message itself.
To load a detached signed message:
TElSignedCMSMessage msg = new TElSignedCMSMessage();
FileStream f = new FileStream("message.p7s", FileMode.Open);
try
{
FileStream dataf = new FileStream("message.dat", FileMode.Open);
try
{
msg.Open(f, dataf);
}
finally
{
dataf.Close();
}
}
finally
{
f.Close();
}