diff --git a/core/modules/update/src/UpdateFetcher.php b/core/modules/update/src/UpdateFetcher.php index e97870b..28cba15 100644 --- a/core/modules/update/src/UpdateFetcher.php +++ b/core/modules/update/src/UpdateFetcher.php @@ -59,6 +59,25 @@ public function __construct(ConfigFactoryInterface $config_factory, ClientInterf */ public function fetchProjectData(array $project, $site_key = '') { $url = $this->buildFetchUrl($project, $site_key); + return $this->doRequestWithHTTPFallback($url, ['headers' => ['Accept' => 'text/xml']], TRUE); + } + + /** + * Applies a GET request with a non https fallback. + * + * This method falls back to not https in case there was some certificate + * problem. + * + * @param string $url + * The URL. + * @param array $options. + * The guzzle client options. + * @param bool $with_non_ssl_fallback + * Should the function callback to NON ssl. + * + * @return string + */ + protected function doRequestWithHTTPFallback($url, array $options, $with_non_ssl_fallback) { $data = ''; try { $data = (string) $this->httpClient @@ -67,6 +86,11 @@ public function fetchProjectData(array $project, $site_key = '') { } catch (RequestException $exception) { watchdog_exception('update', $exception); + + if ($with_non_ssl_fallback && strpos($exception->getMessage(), 'SSL certificate problem: Invalid') !== FALSE) { + $url = str_replace('https://', 'http', $url); + return $this->doRequestWithHTTPFallback($url, $options, FALSE); + } } return $data; }