summaryrefslogtreecommitdiffstats
path: root/settings/ajax
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-08-18 13:57:38 +0200
committerRobin Appelman <icewind@owncloud.com>2014-08-31 10:47:50 +0200
commit6044ad0e174a0d3c9db174115df9c8f61fd43dc3 (patch)
tree6dcf4261c2d691fdb63843882f32f562b6fbb79a /settings/ajax
parentba8416a04fbeb292c00cb10c215bb03fe2f2628f (diff)
downloadnextcloud-server-6044ad0e174a0d3c9db174115df9c8f61fd43dc3.tar.gz
nextcloud-server-6044ad0e174a0d3c9db174115df9c8f61fd43dc3.zip
Cleanup certificate code
Diffstat (limited to 'settings/ajax')
-rw-r--r--settings/ajax/addRootCertificate.php13
1 files changed, 6 insertions, 7 deletions
diff --git a/settings/ajax/addRootCertificate.php b/settings/ajax/addRootCertificate.php
index f055a4066ea..87b1460ef12 100644
--- a/settings/ajax/addRootCertificate.php
+++ b/settings/ajax/addRootCertificate.php
@@ -3,19 +3,18 @@ OCP\JSON::callCheck();
$l = new OC_L10N('core');
-if (!($filename = $_FILES['rootcert_import']['name'])) {
- header('Location:' . OCP\Util::linkToRoute("settings_personal"));
+if (!isset($_FILES['rootcert_import'])) {
+ OCP\JSON::error(array('error' => 'No certificate uploaded'));
exit;
}
-$fh = fopen($_FILES['rootcert_import']['tmp_name'], 'r');
-$data = fread($fh, filesize($_FILES['rootcert_import']['tmp_name']));
-fclose($fh);
-$filename = $_FILES['rootcert_import']['name'];
+$data = file_get_contents($_FILES['rootcert_import']['tmp_name']);
+$filename = basename($_FILES['rootcert_import']['name']);
$certificateManager = \OC::$server->getCertificateManager();
-if ($cert = $certificateManager->addCertificate($data, $filename)) {
+$cert = $certificateManager->addCertificate($data, $filename);
+if ($cert) {
OCP\JSON::success(array(
'name' => $cert->getName(),
'commonName' => $cert->getCommonName(),