All Products
Document Center

Encrypt Messages

Last Updated: Apr 18, 2017


Alibaba Cloud Message Service (MNS) provides services that are accessible over Internet using HTTP. For messages containing sensitive information, how to further increase the security of the network links between a user’s client programs and Alibaba Cloud services? Currently, there are two solutions:

  1. 1. The HTTPS domain name for MNS is made available to users, which is being scheduled to happen mid April.
  2. 2. Messages to transmit are encrypted to avoid being intercepted.

Here are the best practices to encrypt MNS messages to transmit.


  1. Encrypt messages before they are transmitted;

  2. Decrypt the messages at the recipient end before they are consumed;

Sample code (Java):

  1. provides putMessage, popMessage and deleteMessage interfaces.
  • Before sending a message to the server, putMessage encrypts the message with the specified key and encryption algorithm.

  • After receiving the message from the server, popMessage decrypts the message following the specified method and returns the decrypted message.

  1. is used to generate secretKey to encrypt and decrypt messages.

  2. provides a demo program showing how to use SeurityQueue.

See ReadMe in the attachment for more information.


  1. Encrypting and decrypting messages can somehow compromise performance.

  2. Please do not push unencrypted messages to the encrypted message queue.