server = $server; $this->config = $config; } /** {@inheritDoc} */ public function getName() { return 'Update user certificate stores with new root certificates'; } /** {@inheritDoc} */ public function run() { $rootView = new View(); $dataDirectory = $this->config->getSystemValue('datadirectory', null); if(is_null($dataDirectory)) { throw new \Exception('No data directory specified'); } $pathToRootCerts = '/files_external/rootcerts.crt'; foreach($rootView->getDirectoryContent('', 'httpd/unix-directory') as $fileInfo) { $uid = trim($fileInfo->getPath(), '/'); if($rootView->file_exists($uid . $pathToRootCerts)) { // Delete the existing root certificate $rootView->unlink($uid . $pathToRootCerts); /** * FIXME: The certificate manager does only allow specifying the user * within the constructor. This makes DI impossible. */ // Regenerate the certificates $certificateManager = $this->server->getCertificateManager($uid); $certificateManager->createCertificateBundle(); } } } }