Discuss this help topic in SecureBlackbox Forum

EDI: Decrypt an AS2/AS3 message

If encrypted messages are expected, they can be processed the following ways:

  1. You can load all your certificates with their private keys to a certificate storage and assign this storage to Message.Encryption.CertStorage property before calling Load() method. In this case the appropriate certificate for message decryption will be chosen automatically. If there is no appropriate certificate found for message decryption, an EElASMessageError exception will be thrown with SB_AS_ERROR_DECRYPTION_FAILED error code set.
  2. If you don't want all your certificates with their private keys to be loaded to memory all the time, you can use OnDecryptIDs event to find out which certificate is required for the message decryption.

Examples:

C#:


// create an AS2 message
TElAS2Message message = new TElAS2Message();

// load all your certificates with private keys
TElMemoryCertStorage myCertificates = new TElMemoryCertStorage;
myCertificates.LoadFromStreamPFX(...);

// and assign the storage to Encryption.CertStorage
message.Encryption.CertStorage = myCertificates;

// load a message; if the message is encrypted, the appropriate
// certificate will be used automatically
message.Load(messageStream, dataStream);

// then you can check if the message was encrypted or not
if (message.Encryption.Enabled)
    Console.WriteLine(“Encryption algorithm: {0}”, message.Encryption.Algorithm);

How To articles about AS2 and AS3 messages

Discuss this help topic in SecureBlackbox Forum