/**
  * Set Stream parameters: url, data, auth etc.
  *
  * @param array $requestData
  *
  * @return void
  */
 public function prepareRequestBody($requestData)
 {
     $url = parse_url($requestData['url']);
     $headers = array('Content-Type: text/xml', sprintf('Authorization: Basic %s', base64_encode($requestData['user_login'])), sprintf('Content-Length: %s', strlen($requestData['body'])), sprintf('User-Agent: %s', $requestData['user_agent']));
     $contextOptions = array('http' => array('method' => $requestData['type'], 'header' => implode("\r\n", $headers), 'content' => $requestData['body'], 'timeout' => $requestData['timeout']), 'ssl' => array('allow_self_signed' => false, 'cafile' => $requestData['ca_bundle'], 'verify_peer' => true, 'verify_depth' => 10, 'SNI_enabled' => true, 'ciphers' => implode(':', self::getCiphers())));
     // Note: Mitigate CRIME/BEAST attacks
     if (\Genesis\Utils\Common::compareVersions('5.4.13', '>=')) {
         $contextOptions['ssl']['disable_compression'] = true;
     }
     // Note: PHP does NOT support SAN certs on PHP version < 5.6
     if (\Genesis\Utils\Common::compareVersions('5.6.0', '<')) {
         $contextOptions['ssl']['CN_match'] = $url['host'];
         $contextOptions['ssl']['SNI_server_name'] = $url['host'];
     } else {
         $contextOptions['ssl']['peer_name'] = $url['host'];
         $contextOptions['ssl']['verify_peer_name'] = true;
     }
     $this->streamContext = stream_context_create($contextOptions);
     $this->requestData = $requestData;
 }
Пример #2
0
 /**
  * Check the PHP interpreter version we're currently running
  *
  * @throws \Exception
  */
 public static function checkSystemVersion()
 {
     if (\Genesis\Utils\Common::compareVersions('5.3.2', '<')) {
         throw new \Exception(self::getErrorMessage('system'));
     }
 }