private function add_verify(RequestInterface $request, &$options, $value, &$params) { if ($value === true) { // PHP 5.6 or greater will find the system cert by default. When // < 5.6, use the Guzzle bundled cacert. if (PHP_VERSION_ID < 50600) { $options['ssl']['cafile'] = \GuzzleHttp\default_ca_bundle(); } } elseif (is_string($value)) { $options['ssl']['cafile'] = $value; if (!file_exists($value)) { throw new \RuntimeException("SSL CA bundle not found: {$value}"); } } elseif ($value === false) { $options['ssl']['verify_peer'] = false; $options['ssl']['verify_peer_name'] = false; return; } else { throw new \InvalidArgumentException('Invalid verify request option'); } $options['ssl']['verify_peer'] = true; $options['ssl']['verify_peer_name'] = true; $options['ssl']['allow_self_signed'] = false; }
public function testUsesSystemDefaultBundle() { $path = $path = \GuzzleHttp\default_ca_bundle(); $res = $this->getSendResult(['verify' => true]); $opts = stream_context_get_options($res->getBody()->detach()); if (PHP_VERSION_ID < 50600) { $this->assertEquals($path, $opts['ssl']['cafile']); } }
/** * Check if we can/should use SSL/TLS/HTTP2 or HTTP. * * @return boolean */ public function useSsl() { if ($this->useSsl !== null) { return $this->useSsl; } if (!extension_loaded('openssl')) { return $this->useSsl = false; } try { if ($this->app['guzzle.api_version'] === 5) { ClientUtils::getDefaultCaBundle(); } else { \GuzzleHttp\default_ca_bundle(); } return $this->useSsl = true; } catch (\RuntimeException $e) { $this->messages[] = $e->getMessage(); return $this->useSsl = false; } }
/** * Check if we can/should use SSL/TLS/HTTP2 or HTTP. * * @return boolean */ public function useSsl() { if ($this->useSsl !== null) { return $this->useSsl; } if (!extension_loaded('openssl')) { return $this->useSsl = false; } if (preg_match('{^http:}i', $this->app['extend.site'])) { return $this->useSsl = false; } try { \GuzzleHttp\default_ca_bundle(); return $this->useSsl = true; } catch (\RuntimeException $e) { $this->messages[] = $e->getMessage(); return $this->useSsl = false; } }