Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System Check - Add a reminder about CIVICRM_SIGN_KEYS. #23224

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions CRM/Utils/Check/Component/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,41 @@ public function checkDirectoriesAreNotBrowseable() {
return $messages;
}

/**
* Check that the site is configured with a signing-key.
*
* The current infrastructure for signatures was introduced circa 5.36. Specifically,
* most sites should now define `CIVICRM_SIGN_KEYS`. However, this could be missing for
* sites which either (a) upgraded from an earlier release or (b) used an unpatched installer.
*
* @return CRM_Utils_Check_Message[]
*/
public function checkSigningKey(): array {
$messages = [];

try {
$found = !empty(Civi::service('crypto.registry')->findKey('SIGN'));
// Subtle point: We really want to know if there are any `SIGN`ing keys. The most
// typical way to define `SIGN`ing keys is to configure `CIVICRM_SIGN_KEYS`.
}
catch (\Civi\Crypto\Exception\CryptoException $e) {
$found = FALSE;
}
if (!$found) {
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
ts('Some components and extensions may need to generate cryptographic signatures. Please configure <a %1>CIVICRM_SIGN_KEYS</a>. ',
[1 => 'href="https://docs.civicrm.org/sysadmin/en/latest/setup/secret-keys/" target="_blank"']
),
ts('Signing Key Recommended'),
\Psr\Log\LogLevel::NOTICE,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agh1 What do you think of NOTICE here?

'fa-lock'
);
}

return $messages;
}

/**
* Check that some files are not present.
*
Expand Down