summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-08-13 16:46:04 +0200
committerRobin Appelman <icewind@owncloud.com>2014-08-13 16:46:04 +0200
commit9509bc403a4f05c96b88e1218e6c7a78f9dd6c20 (patch)
treefe53373a52eae1d86867540a7005dcdc19bc0846
parent54491e8c68a1973bf6ea3622310fba68bf9d4f43 (diff)
downloadnextcloud-server-9509bc403a4f05c96b88e1218e6c7a78f9dd6c20.tar.gz
nextcloud-server-9509bc403a4f05c96b88e1218e6c7a78f9dd6c20.zip
Give a better error message for external shares with self-signed ssl certificates
-rw-r--r--apps/files_sharing/ajax/external.php28
1 files changed, 17 insertions, 11 deletions
diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php
index 0dbd3ab8c95..390d5bfb9d8 100644
--- a/apps/files_sharing/ajax/external.php
+++ b/apps/files_sharing/ajax/external.php
@@ -33,16 +33,22 @@ $externalManager = new \OCA\Files_Sharing\External\Manager(
$name = OCP\Files::buildNotExistingFileName('/', $name);
-$mount = $externalManager->addShare($remote, $token, $password, $name, $owner);
-/**
- * @var \OCA\Files_Sharing\External\Storage $storage
- */
-$storage = $mount->getStorage();
-$result = $storage->file_exists('');
-if($result){
- $storage->getScanner()->scanAll();
- \OCP\JSON::success();
+// check for ssl cert
+if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) {
+ \OCP\JSON::error(array('data' => array('message' => $l->t("Invalid or untrusted ssl certificate"))));
+ exit;
} else {
- $externalManager->removeShare($mount->getMountPoint());
- \OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't add remote share"))));
+ $mount = $externalManager->addShare($remote, $token, $password, $name, $owner);
+ /**
+ * @var \OCA\Files_Sharing\External\Storage $storage
+ */
+ $storage = $mount->getStorage();
+ $result = $storage->file_exists('');
+ if ($result) {
+ $storage->getScanner()->scanAll();
+ \OCP\JSON::success();
+ } else {
+ $externalManager->removeShare($mount->getMountPoint());
+ \OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't add remote share"))));
+ }
}