You are here

private function StreamHandler::add_verify in Lockr 7.3

File

vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php, line 421

Class

StreamHandler
HTTP handler that uses PHP's HTTP stream wrapper.

Namespace

GuzzleHttp\Handler

Code

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;
}