summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2012-07-06 15:58:38 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2012-07-06 15:58:38 +0200
commite91b4bc2ac79f8855c57accfce2558ead52d2943 (patch)
tree34d05ca1db5da46aa114e01364f729a03aff2054 /apps/files_external/lib
parent75d01b065da91acb7512b3df82d69c8d931c50b3 (diff)
downloadnextcloud-server-e91b4bc2ac79f8855c57accfce2558ead52d2943.tar.gz
nextcloud-server-e91b4bc2ac79f8855c57accfce2558ead52d2943.zip
allow user to upload his own root certificate for secure webdav mount
Diffstat (limited to 'apps/files_external/lib')
-rwxr-xr-xapps/files_external/lib/config.php27
-rw-r--r--apps/files_external/lib/webdav.php2
2 files changed, 27 insertions, 2 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 4e82e6b2548..5630df77a91 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -244,7 +244,8 @@ class OC_Mount_Config {
*/
public static function getCertificates() {
$view = \OCP\Files::getStorage('files_external');
- $path=\OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("");
+ $path=\OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").'uploads/';
+ if (!is_dir($path)) mkdir($path);
$result = array();
$handle = opendir($path);
while (false !== ($file = readdir($handle))) {
@@ -252,6 +253,30 @@ class OC_Mount_Config {
}
return $result;
}
+
+ /**
+ * creates certificate bundle
+ */
+ public static function createCertificateBundle() {
+ $view = \OCP\Files::getStorage("files_external");
+ $path = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("");
+
+ $certs = OC_Mount_Config::getCertificates();
+ $fh_certs = fopen($path."/rootcerts.crt", 'w');
+ foreach ($certs as $cert) {
+ $file=$path.'/uploads/'.$cert;
+ $fh = fopen($file, "r");
+ $data = fread($fh, filesize($file));
+ fclose($fh);
+ if (strpos($data, 'BEGIN CERTIFICATE')) {
+ fwrite($fh_certs, $data);
+ }
+ }
+
+ fclose($fh_certs);
+
+ return true;
+ }
}
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index 9b874e62e33..ea6ca65b976 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -45,7 +45,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$this->client = new OC_Connector_Sabre_Client($settings);
if($caview = \OCP\Files::getStorage('files_external')) {
- $this->client->setCurlSettings(array(CURLOPT_CAPATH => \OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("")));
+ $this->client->setCurlSettings(array(CURLOPT_CAINFO => \OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt'));
}
//create the root folder if necesary
$this->mkdir('');