Invalid PEM format triggers key validation errors in Adobe Commerce

In Adobe Commerce, key validation errors occur when configuring API keys for Adobe Payment Services in the Commerce Services Connector. These errors appear when the private key PEM(Privacy-Enhanced Mail) file is not formatted correctly. To fix this issue, correct the PEM(Privacy-Enhanced Mail) file format so the Base64 content is properly separated from the header and footer.

Description description

Environment

Product: Adobe Commerce

Issue/Symptoms

The following symptoms occur during setup:

  • Error messages state Public key is invalid and Private key is invalid when adding sandbox keys.
  • The private key fails validation due to improper PEM formatting, with the key content placed on the same line as the header or footer.

Resolution resolution

To fix this issue, follow these steps:

  1. Ensure that the private key PEM file has its Base64 content on separate lines between the header and footer, with no extra characters or leading spaces. Learn more in Commerce Services Connector.

  2. If there are extra characters or leading spaces, you can normalize your sandbox using the sandbox private key below:

    code language-none
    awk '
    function trim(s){ sub(/[  \t\r\n] +/, "", s); sub(/[  \t\r\n] +$/, "", s); return s }
    
    # BEGIN/END lines: print as-is (trimmed), no extra newlines
    /-----BEGIN / { print trim($0); next }
    /-----END /   { print trim($0); next }
    
    # Body: remove *all* whitespace then wrap at 64 chars
    {
      line = trim($0)
      gsub(/[  \t\r\n] /, "", line)
      while (length(line) > 64) { print substr(line,1,64); line = substr(line,65) }
      if (length(line)) print line
    }' <key_incorrect_oneline.pem> > <key_normalized_multiline.pem>
    
  3. Enter the corrected Sandbox private key into the Commerce Services Connector configuration. Learn more in Commerce Services Connector.

  4. If successful, repeat with a normalized Production private key.

  5. Refresh the Commerce Services Connector page.

  6. Re-validate both public and private keys in the connector interface.

  7. Verify that no further invalid key errors appear.

Note

  • Public keys for both Sandbox and Production do not require changes.
  • The normalized PEM files should be used as provided or generated according to standard PEM formatting requirements (Base64 data wrapped at 64 characters per line).
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f