Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-08-18 15:57:38 +0400
committerRobin Appelman <icewind@owncloud.com>2014-08-31 12:47:50 +0400
commit6044ad0e174a0d3c9db174115df9c8f61fd43dc3 (patch)
tree6dcf4261c2d691fdb63843882f32f562b6fbb79a /settings/ajax
parentba8416a04fbeb292c00cb10c215bb03fe2f2628f (diff)
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(),