diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-08-15 17:18:46 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-08-31 10:47:50 +0200 |
commit | c1b11571ea53748d57241598dec71750637416cd (patch) | |
tree | c823c19b77fe4aa62142299ffe5df6b6421be63a /settings/ajax | |
parent | 298011bf296a4eda62b787bb7c8fbfe30644d488 (diff) | |
download | nextcloud-server-c1b11571ea53748d57241598dec71750637416cd.tar.gz nextcloud-server-c1b11571ea53748d57241598dec71750637416cd.zip |
Move certificate management interface from files_external to core
Diffstat (limited to 'settings/ajax')
-rw-r--r-- | settings/ajax/addRootCertificate.php | 34 | ||||
-rw-r--r-- | settings/ajax/removeRootCertificate.php | 9 |
2 files changed, 43 insertions, 0 deletions
diff --git a/settings/ajax/addRootCertificate.php b/settings/ajax/addRootCertificate.php new file mode 100644 index 00000000000..9be8fd0025b --- /dev/null +++ b/settings/ajax/addRootCertificate.php @@ -0,0 +1,34 @@ +<?php + +OCP\JSON::checkAppEnabled('files_external'); +OCP\JSON::callCheck(); + +$l = new OC_L10N('core'); + +if (!($filename = $_FILES['rootcert_import']['name'])) { + header('Location:' . OCP\Util::linkToRoute("settings_personal")); + 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']; + +$certificateManager = \OC::$server->getCertificateManager(); + +if ($cert = $certificateManager->addCertificate($data, $filename)) { + OCP\JSON::success(array( + 'name' => $cert->getName(), + 'commonName' => $cert->getCommonName(), + 'organization' => $cert->getOrganization(), + 'validFrom' => $cert->getIssueDate()->getTimestamp(), + 'validTill' => $cert->getExpireDate()->getTimestamp(), + 'validFromString' => $l->l('date', $cert->getIssueDate()), + 'validTillString' => $l->l('date', $cert->getExpireDate()), + 'issuer' => $cert->getIssuerName(), + 'issuerOrganization' => $cert->getIssuerOrganization() + )); +} else { + OCP\JSON::error(array('error' => 'Couldn\'t import SSL root certificate, allowed formats: PEM and DER')); +} diff --git a/settings/ajax/removeRootCertificate.php b/settings/ajax/removeRootCertificate.php new file mode 100644 index 00000000000..0931138ad4b --- /dev/null +++ b/settings/ajax/removeRootCertificate.php @@ -0,0 +1,9 @@ +<?php + +OCP\JSON::checkAppEnabled('files_external'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + +$name = $_POST['cert']; +$certificateManager = \OC::$server->getCertificateManager(); +$certificateManager->removeCertificate($name); |