Resolve issues with encryption key

This topic discusses solutions to typical issues you might experience with Magento EE encryption key in your environments.

For a new Starter project, the Magento encryption key is on your master branch Production environment. When you branch to other environments, the key travels with the code and database.

For a new Pro project starting with a “blank site” Magento Commerce (Cloud) template, the Magento encryption key is on the Integration master branch and environment until you initially deploy across all environments.

If you have imported data from an existing Magento installation into Magento Commerce (Cloud), you need to copy the key and deploy it to the environments.

Encryption key not in all environments

All Cloud environments require this encryption key in all three environments or the store will encounter authentication and authorization errors for actions like completing a payment on a cart, processing a return, and adding shipping to orders.

To verify and update the encryption key environment variable:

  1. SSH to each of the Cloud environments: Integration, Staging, and Production.

    magento-cloud environment:ssh
    
  2. Open app/etc/env.php in a text editor.
  3. Verify the existing value of key for crypt. The value should be your Magento EE key.
        return array (
          'crypt' =>
          array (
            'key' => '<your encryption key>',
          ),
        );
        
  1. If the value is incorrect, add the key value, and save your changes to env.php.
  2. Exit the text editor and repeat this process for each environment. Test store actions in each environment to verify if the issue persists, such as completing a cart purchase.