summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-03-23 14:33:25 +0100
committerBjoern Schiessle <bjoern@schiessle.org>2017-03-24 11:06:44 +0100
commit33867f331cdb1d9c678609e4aacc3166ec937629 (patch)
tree15d027c489f26006c363d6addb12fe031a8b0c5a /apps
parentaa26a3ae749f624de63f9a274ff23d21c5160658 (diff)
downloadnextcloud-server-33867f331cdb1d9c678609e4aacc3166ec937629.tar.gz
nextcloud-server-33867f331cdb1d9c678609e4aacc3166ec937629.zip
Load cert file before syncing addressbooks and contacts
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/CardDAV/SyncService.php47
1 files changed, 31 insertions, 16 deletions
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php
index 1293d8ae8a0..b0a4ce81e70 100644
--- a/apps/dav/lib/CardDAV/SyncService.php
+++ b/apps/dav/lib/CardDAV/SyncService.php
@@ -52,6 +52,9 @@ class SyncService {
/** @var AccountManager */
private $accountManager;
+ /** @var string */
+ protected $certPath;
+
/**
* SyncService constructor.
*
@@ -65,6 +68,12 @@ class SyncService {
$this->userManager = $userManager;
$this->logger = $logger;
$this->accountManager = $accountManager;
+
+ $certManager = \OC::$server->getCertificateManager(null);
+ $certPath = $certManager->getAbsoluteBundlePath();
+ if (file_exists($certPath)) {
+ $this->certPath = $certPath;
+ }
}
/**
@@ -136,10 +145,9 @@ class SyncService {
* @param string $url
* @param string $userName
* @param string $sharedSecret
- * @param string $syncToken
- * @return array
+ * @return Client
*/
- protected function requestSyncReport($url, $userName, $sharedSecret, $syncToken) {
+ protected function getClient($url, $userName, $sharedSecret) {
$settings = [
'baseUri' => $url . '/',
'userName' => $userName,
@@ -148,6 +156,23 @@ class SyncService {
$client = new Client($settings);
$client->setThrowExceptions(true);
+ if (strpos($url, 'http://') !== 0 && $this->certPath) {
+ $client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
+ }
+
+ return $client;
+ }
+
+ /**
+ * @param string $url
+ * @param string $userName
+ * @param string $sharedSecret
+ * @param string $syncToken
+ * @return array
+ */
+ protected function requestSyncReport($url, $userName, $sharedSecret, $syncToken) {
+ $client = $this->getClient($url, $userName, $sharedSecret);
+
$addressBookUrl = "remote.php/dav/addressbooks/system/system/system";
$body = $this->buildSyncCollectionRequestBody($syncToken);
@@ -155,9 +180,7 @@ class SyncService {
'Content-Type' => 'application/xml'
]);
- $result = $this->parseMultiStatus($response['body']);
-
- return $result;
+ return $this->parseMultiStatus($response['body']);
}
/**
@@ -167,16 +190,8 @@ class SyncService {
* @return array
*/
protected function download($url, $sharedSecret, $resourcePath) {
- $settings = [
- 'baseUri' => $url,
- 'userName' => 'system',
- 'password' => $sharedSecret,
- ];
- $client = new Client($settings);
- $client->setThrowExceptions(true);
-
- $response = $client->request('GET', $resourcePath);
- return $response;
+ $client = $this->getClient($url, 'system', $sharedSecret);
+ return $client->request('GET', $resourcePath);
}
/**