From 7975b748163592c4414f0f07382169154662e6ca Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 13 Aug 2014 16:46:04 +0200 Subject: [PATCH] Give a better error message for external shares with self-signed ssl certificates --- apps/files_sharing/ajax/external.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php index 5caa29e79e2..c5e78a3bbb5 100644 --- a/apps/files_sharing/ajax/external.php +++ b/apps/files_sharing/ajax/external.php @@ -39,16 +39,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")))); + } } -- 2.39.5