/** * Returns an array of default curl settings to use * * @param RequestInterface $request * @return array */ private function getCurlDefaultOptions(RequestInterface $request) { return array(CURLOPT_URL => $request->getUri(), CURLOPT_PORT => $request->getPort(), CURLOPT_CUSTOMREQUEST => $request->getMethod(), CURLOPT_HTTPHEADER => $request->getHeaderFields(), CURLOPT_TIMEOUT => 10, CURLOPT_SSL_VERIFYPEER => 1, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_CAINFO => __DIR__ . '/ca-bundle.crt', CURLOPT_RETURNTRANSFER => true, CURLOPT_FORBID_REUSE => 1, CURLOPT_FRESH_CONNECT => 1, CURLOPT_HEADER => true); }
/** * @param RequestInterface $request * @throws \Exception */ protected function addSignatureHeader(RequestInterface $request) { if (null === $this->privateKey) { throw new \Exception('Please set your Private Key'); } if (true == property_exists($this->network, 'isPortRequiredInUrl')) { if ($this->network->isPortRequiredInUrl === true) { $url = $request->getUriWithPort(); } else { $url = $request->getUri(); } } else { $url = $request->getUri(); } $message = sprintf('%s%s', $url, $request->getBody()); $signature = $this->privateKey->sign($message); $request->setHeader('x-signature', $signature); }