/** * Sets the default options to the client */ private function setDefaultOptions() { // Either use default bundle or the user bundle if nothing is specified if ($this->certificateManager->listCertificates() !== []) { $dataDir = $this->config->getSystemValue('datadirectory'); $this->client->setDefaultOption('verify', $dataDir . '/' . $this->certificateManager->getCertificateBundle()); } else { $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/config/ca-bundle.crt'); } $this->client->setDefaultOption('headers/User-Agent', 'ownCloud Server Crawler'); if ($this->getProxyUri() !== '') { $this->client->setDefaultOption('proxy', $this->getProxyUri()); } }
public function getShareInfo() { $remote = $this->getRemote(); $token = $this->getToken(); $password = $this->getPassword(); $url = $remote . '/index.php/apps/files_sharing/shareinfo?t=' . $token; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('password' => $password))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); $path = $this->certificateManager->getCertificateBundle(); if (is_readable($path)) { curl_setopt($ch, CURLOPT_CAINFO, $path); } $result = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); $errorMessage = curl_error($ch); curl_close($ch); if (!empty($errorMessage)) { throw new \Exception($errorMessage); } switch ($status) { case 401: case 403: throw new ForbiddenException(); case 404: throw new NotFoundException(); case 500: throw new \Exception(); } return json_decode($result, true); }