function salesforce_get_tls_requirements in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 salesforce.install \salesforce_get_tls_requirements()
- 8.3 salesforce.install \salesforce_get_tls_requirements()
Return TLS requirements array.
1 call to salesforce_get_tls_requirements()
- salesforce_requirements in ./
salesforce.install - Implements hook_requirements().
File
- ./
salesforce.install, line 134 - Salesforce install file.
Code
function salesforce_get_tls_requirements() {
$response = \Drupal::state()
->get('salesforce.tls_status', FALSE);
$last = \Drupal::state()
->get('salesforce.last_requirements_check', 0);
$last = \Drupal::service('date.formatter')
->format($last);
$requirements = [
'title' => t('Salesforce TLS'),
'value' => t('TLS 1.1+ Support last checked %time', [
'%time' => $last,
]),
];
// If we didn't get a good response, throw a warning.
if (empty($response) || empty($response['tls_version'])) {
$requirements += [
'severity' => REQUIREMENT_WARNING,
'description' => t('Drupal failed to connect to https://www.howsmyssl.com/a/check service to check TLS 1.1+ support for this client. Please ensure your OpenSSL client supports TLS 1.1+ before using Salesforce module.'),
];
}
else {
// If we got a good response, and this client doesn't support TLS1.1+, throw
// an error.
switch ($response['tls_version']) {
case 'TLS 1.1':
case 'TLS 1.2':
case 'TLS 1.3':
$requirements += [
'severity' => REQUIREMENT_OK,
'description' => t('OK: %version', [
'%version' => $response['tls_version'],
]),
];
break;
default:
$requirements += [
'severity' => REQUIREMENT_ERROR,
'description' => t('Unsupported: %version -- Salesforce API requires TLS 1.1+. Please upgrade your OpenSSL version before using Salesforce module.', [
'%version' => $response['tls_version'],
]),
];
break;
}
}
return $requirements;
}