Integration Server 10.5 | MIME-S/MIME Developer’s Guide | Building MIME and S/MIME Messages | Encrypting a MIME Message | How to Create an Encrypted S/MIME Message
 
How to Create an Encrypted S/MIME Message
The following procedure describes the general steps you take to create an encrypted S/MIME message.
Important:
If you want to create a signed and encrypted MIME message, use the special service that Integration Server provides for this purpose. For instructions, see Signing and Encrypting a MIME Message.
1. Create an InputStream containing the MIME message that you want to encrypt. You can use the procedure outlined in How to Create a MIME Message to create the MIME message.
2. Fetch the recipient’s certificate as a byte[]. If the message will be sent to multiple recipients, fetch the certificate of each recipient. Load the certificates into a list (a one-dimensional array) of byte[] such that each element in the list holds the certificate of single recipient.
3. Pass the certificate and the MIME message to the pub.smime:createEncryptedData service. This service encrypts the InputStream containing the MIME message and produces a new InputStream containing the encrypted message.