Resolve issues with encryption key
When you import a database dump to another environment, the encryption key remains in the source environment. This article explains how to transfer the encryption key to resolve payment and saved data issues.
Description description
Environment
Adobe Commerce on cloud infrastructure 2.4.x
Issue/Symptoms
After importing a database dump from Production to Staging/Integration environments, you experience one or more of the following:
- Saved credit card numbers appear incorrect
- Payments fail for payment integrations that require merchant credentials
- Stored payment method data is corrupted
Cause
The encryption key used to encrypt sensitive data (such as credit card numbers and merchant credentials) is not stored in the database. Therefore, it is not transferred to other environments when you import or export a database dump.
Resolution resolution
You must copy the encryption key from the source environment and add it to the destination environment.
To copy the encryption key:
- SSH to your project that was the source for the database dump, as described in SSH to environment in our developer documentation.
- Open
app/etc/env.phpin a text editor. - Copy the value of
keyforcrypt.
return array(
'crypt' => array(
'key' => '',
),
);
To set the key value for the destination project:
- Open the Cloud Console and locate your project.
- Set the value of the CRYPT_KEY (in our developer documentation) variable, as described in Configure your project in our developer documentation. This will trigger the deployment process and
CRYPT_KEYwill be overridden in theapp/etc/env.phpfile on every deployment.
Optionally, you can manually override the encryption key in the app/etc/env.php file:
- SSH to the destination environment.
- Open
app/etc/env.phpin a text editor. - Paste the copied data as the
keyvalue forcrypt. - Save the edited
env.php. - Clean cache on the destination environment by running
bin/magentocache:cleanor in the Commerce Admin under System>Tools>Cache Management.