InvalidCertificatesRequirement.php in Acquia Content Hub 8
File
acquia_contenthub_diagnostic/src/Plugin/ContentHubRequirement/InvalidCertificatesRequirement.php
View source
<?php
namespace Drupal\acquia_contenthub_diagnostic\Plugin\ContentHubRequirement;
use Drupal\acquia_contenthub_diagnostic\ContentHubRequirementBase;
class InvalidCertificatesRequirement extends ContentHubRequirementBase {
public function verify() {
$domain = $this
->getDomain();
try {
$client = \Drupal::httpClient();
$request = $client
->get($domain);
if ($request
->getStatusCode() != 200) {
throw new \Exception($this
->t('Status 200 not returned.'));
}
} catch (\Exception $e) {
$this
->setValue($this
->t('Certificate cannot be validated'));
$this
->setDescription($this
->t("Your site's homepage could not be reached over HTTPS. Verify your server configuration to ensure the site is reachable via HTTPS and uses valid SSL certificates. Error: @error", [
'@error' => $e
->getMessage(),
]));
return REQUIREMENT_ERROR;
}
return REQUIREMENT_OK;
}
}