diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2012-07-06 15:58:38 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2012-07-06 15:58:38 +0200 |
commit | e91b4bc2ac79f8855c57accfce2558ead52d2943 (patch) | |
tree | 34d05ca1db5da46aa114e01364f729a03aff2054 /apps/files_external/ajax | |
parent | 75d01b065da91acb7512b3df82d69c8d931c50b3 (diff) | |
download | nextcloud-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/ajax')
-rw-r--r-- | apps/files_external/ajax/addRootCertificate.php | 16 | ||||
-rw-r--r-- | apps/files_external/ajax/removeRootCertificate.php | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/apps/files_external/ajax/addRootCertificate.php b/apps/files_external/ajax/addRootCertificate.php index 33cd64d2c7a..c1928556292 100644 --- a/apps/files_external/ajax/addRootCertificate.php +++ b/apps/files_external/ajax/addRootCertificate.php @@ -4,9 +4,23 @@ OCP\JSON::checkAppEnabled('files_external'); $view = \OCP\Files::getStorage("files_external"); $from = $_FILES['rootcert_import']['tmp_name']; -$to = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").$_FILES['rootcert_import']['name']; +$path = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").'uploads/'; +$to = $path.$_FILES['rootcert_import']['name']; move_uploaded_file($from, $to); +//check if it is a PEM certificate, otherwise convert it if possible +$fh = fopen($to, 'r'); +$data = fread($fh, filesize($to)); +fclose($fh); +if (!strpos($data, 'BEGIN CERTIFICATE')) { + $pem = chunk_split(base64_encode($data), 64, "\n");
+ $pem = "-----BEGIN CERTIFICATE-----\n".$pem."-----END CERTIFICATE-----\n"; + $fh = fopen($to, 'w'); + fwrite($fh, $pem); +} + +OC_Mount_Config::createCertificateBundle(); + header("Location: settings/personal.php"); exit; ?>
\ No newline at end of file diff --git a/apps/files_external/ajax/removeRootCertificate.php b/apps/files_external/ajax/removeRootCertificate.php index 05f2fdef2d1..a00922f4210 100644 --- a/apps/files_external/ajax/removeRootCertificate.php +++ b/apps/files_external/ajax/removeRootCertificate.php @@ -4,6 +4,7 @@ OCP\JSON::checkAppEnabled('files_external'); $view = \OCP\Files::getStorage("files_external"); $cert = $_POST['cert']; -$file = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").$cert; +$file = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").'uploads/'.$cert; unlink($file); +OC_Mount_Config::createCertificateBundle(); ?>
\ No newline at end of file |