/**
  * Test deleteCertificate().
  *
  * @param Certificate $certificate
  *
  * @dataProvider certificateProvider
  */
 public function testDeleteCertificate(Certificate $certificate)
 {
     $this->_builder->saveCertificate($certificate);
     $paths = array($certificate->getCertificateFilePath(), $certificate->getCertificateKeyFilePath(), $certificate->getCACertificateFilePath(), $certificate->getCertificateChainFilePath());
     $this->_builder->deleteCertificate($certificate);
     foreach ($paths as $path) {
         if (!empty($path)) {
             $this->assertFileNotExists($path);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Save certificates.
  * For Lighttpd, merge some files into others.
  *
  * @param Certificate $certificate
  */
 public function saveCertificate(Certificate $certificate)
 {
     $fs = new Filesystem();
     parent::saveCertificate($certificate);
     /**
      * Merge Key into Cert-File,
      * and merge Chain into CA-Cert file.
      */
     $keyfile = $certificate->getCertificateKeyFilePath();
     $chainfile = $certificate->getCertificateChainFilePath();
     $cafilepath = $certificate->getCACertificateFilePath();
     $certfilepath = $certificate->getCertificateFilePath();
     if (!empty($keyfile) && $fs->exists($certfilepath)) {
         file_put_contents($certfilepath, PHP_EOL . file_get_contents($keyfile), FILE_APPEND);
     }
     if (!empty($chainfile) && $fs->exists($cafilepath)) {
         file_put_contents($cafilepath, PHP_EOL . file_get_contents($chainfile), FILE_APPEND);
     }
 }