diff options
author | Carlos Cerrillo <ccerrillo@gmail.com> | 2013-12-15 17:22:52 +0100 |
---|---|---|
committer | Carlos Cerrillo <ccerrillo@gmail.com> | 2013-12-15 17:22:52 +0100 |
commit | 7c264c88fe06c61ef602fa8a241428c99f220061 (patch) | |
tree | d663fc8261a32bba14f669a3e1822b3b2eed6d2e | |
parent | 77b68505c2164330803ce5d5dcbb9fd07438e18d (diff) | |
download | nextcloud-server-7c264c88fe06c61ef602fa8a241428c99f220061.tar.gz nextcloud-server-7c264c88fe06c61ef602fa8a241428c99f220061.zip |
Fixing Issue #6301 on master branch
Added private var $certPath to store the user root cert
Move logic to determine the $certPath path to the constructor and modify to get the path from OC_User::getHome()
Add curl options to use the certificate to avoid certificate errors with self-signed certicates in the downdload/upload method so we don't get blank files
-rw-r--r-- | apps/files_external/lib/webdav.php | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 02f6cb5fc4f..2308c7873b8 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -14,6 +14,7 @@ class DAV extends \OC\Files\Storage\Common{ private $host; private $secure; private $root; + private $certPath; private $ready; /** * @var \Sabre_DAV_Client @@ -40,6 +41,12 @@ class DAV extends \OC\Files\Storage\Common{ } else { $this->secure = false; } + if ($this->secure === true) { + $certPath=\OC_User::getHome(\OC_User::getUser()) . '/files_external/rootcerts.crt'; + if (file_exists($certPath)) { + $this->certPath=$certPath; + } + } $this->root=isset($params['root'])?$params['root']:'/'; if ( ! $this->root || $this->root[0]!='/') { $this->root='/'.$this->root; @@ -66,12 +73,8 @@ class DAV extends \OC\Files\Storage\Common{ $this->client = new \Sabre_DAV_Client($settings); - $caview = \OCP\Files::getStorage('files_external'); - if ($caview) { - $certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt'; - if (file_exists($certPath)) { - $this->client->addTrustedCertificates($certPath); - } + if ($this->certPath) { + $this->client->addTrustedCertificates($this->certPath); } } @@ -166,6 +169,11 @@ class DAV extends \OC\Files\Storage\Common{ curl_setopt($curl, CURLOPT_URL, $this->createBaseUri().str_replace(' ', '%20', $path)); curl_setopt($curl, CURLOPT_FILE, $fp); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); + if($this->certPath){ + curl_setopt($curl, CURLOPT_CAINFO, $this->certPath); + } curl_exec ($curl); curl_close ($curl); @@ -254,6 +262,11 @@ class DAV extends \OC\Files\Storage\Common{ curl_setopt($curl, CURLOPT_INFILE, $source); // file pointer curl_setopt($curl, CURLOPT_INFILESIZE, filesize($path)); curl_setopt($curl, CURLOPT_PUT, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); + if($this->certPath){ + curl_setopt($curl, CURLOPT_CAINFO, $this->certPath); + } curl_exec ($curl); curl_close ($curl); } @@ -331,3 +344,4 @@ class DAV extends \OC\Files\Storage\Common{ } } } + |