Support DKIM for domain verification

Created on 31 May 2023, about 1 year ago
Updated 5 June 2023, about 1 year ago

Problem/Motivation

Cannot access Verified Identities page (/admin/config/system/amazon_ses/settings/identities) if one or more AWS SES identities has not completed DKIM setup. (I know, the identity needs to be finalized, but we should at least not have a fatal error.)

Steps to reproduce

  1. Install module (v3.0.1, 3.0.x-dev)
  2. Configure AWS profile at /admin/config/services/aws
  3. Have at least one profile at AWS that does not have DKIM setup up
  4. Attempt to visit /admin/config/system/amazon_ses/settings/identities
  5. Receive error:
    TypeError: reset(): Argument #1 ($array) must be of type array, null given in reset() (line 159 of modules/contrib/amazon_ses/src/AmazonSesHandler.php).

Proposed resolution

In src/AmazonSesHandler.php, in the method getIdentities(), there's a line that grabs the DKIM attributes using:

$attributes = $result['DkimAttributes'];

The attributes array has a key of SigningEnabled which is a boolean. Either that, or a check if the Tokens key exists should be done.

        if ($domain && isset($attributes['Tokens'])) {
          $item['token'] = reset($attributes['Tokens']);
        }

This stops the fatal error, however a warning is then raised:

Warning: Undefined array key "token" in Drupal\amazon_ses\Form\AmazonSesIdentitiesForm->buildForm() (line 51 of modules/contrib/amazon_ses/src/Form/AmazonSesIdentitiesForm.php).

I haven't had a chance to dive deeper yet, unfortunately

Remaining tasks

Determine if this is the best path in the first place, or if something else needs to be done instead.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024