Verify names of certificates

This commit is contained in:
Robin Appelman 2014-08-14 15:47:23 +02:00
parent c2ebc192a6
commit dcc4f96d3e
2 changed files with 11 additions and 4 deletions

View File

@ -6,6 +6,4 @@ OCP\JSON::callCheck();
$name = $_POST['cert'];
$certificateManager = \OC::$server->getCertificateManager();
if (\OC\Files\Filesystem::isValidPath($name)) {
$certificateManager->removeCertificate($name);
}
$certificateManager->removeCertificate($name);

View File

@ -8,10 +8,12 @@
namespace OC;
use OCP\ICertificateManager;
/**
* Manage trusted certificates for users
*/
class CertificateManager {
class CertificateManager implements ICertificateManager {
/**
* @var \OCP\IUser
*/
@ -76,6 +78,9 @@ class CertificateManager {
* @return bool
*/
public function addCertificate($certificate, $name) {
if (!\OC\Files\Filesystem::isValidPath($name)) {
return false;
}
$isValid = openssl_pkey_get_public($certificate);
if (!$isValid) {
@ -96,8 +101,12 @@ class CertificateManager {
/**
* @param string $name
* @return bool
*/
public function removeCertificate($name) {
if (!\OC\Files\Filesystem::isValidPath($name)) {
return false;
}
$path = $this->user->getHome() . '/files_external/uploads/';
if (file_exists($path . $name)) {
unlink($path . $name);