diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-08-31 15:50:30 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-08-31 15:50:30 +0200 |
commit | 8009df0b60c71bac41e4ead9ec8e4e92812e0d75 (patch) | |
tree | a937e0948af28bffff46eb08f24c93712032d26a /settings/ajax | |
parent | 73685892ed6f255a916512863cd5549914d071e1 (diff) | |
parent | 3a85767182e04ac013f59d82cc3a8c4d08bab151 (diff) | |
download | nextcloud-server-8009df0b60c71bac41e4ead9ec8e4e92812e0d75.tar.gz nextcloud-server-8009df0b60c71bac41e4ead9ec8e4e92812e0d75.zip |
Merge pull request #10420 from owncloud/external-share-self-signed
Make external shares work with imported self signed certificates
Diffstat (limited to 'settings/ajax')
-rw-r--r-- | settings/ajax/addRootCertificate.php | 32 | ||||
-rw-r--r-- | settings/ajax/removeRootCertificate.php | 7 |
2 files changed, 39 insertions, 0 deletions
diff --git a/settings/ajax/addRootCertificate.php b/settings/ajax/addRootCertificate.php new file mode 100644 index 00000000000..378ef39c1e5 --- /dev/null +++ b/settings/ajax/addRootCertificate.php @@ -0,0 +1,32 @@ +<?php +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + +$l = new OC_L10N('core'); + +if (!isset($_FILES['rootcert_import'])) { + OCP\JSON::error(array('error' => 'No certificate uploaded')); + exit; +} + +$data = file_get_contents($_FILES['rootcert_import']['tmp_name']); +$filename = basename($_FILES['rootcert_import']['name']); + +$certificateManager = \OC::$server->getCertificateManager(); + +try { + $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() + )); +} catch(\Exception $e) { + 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..a3de035269e --- /dev/null +++ b/settings/ajax/removeRootCertificate.php @@ -0,0 +1,7 @@ +<?php +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + +$name = $_POST['cert']; +$certificateManager = \OC::$server->getCertificateManager(); +$certificateManager->removeCertificate($name); |