diff --git a/web/Modules/LetsEncrypt/Filament/Clusters/LetsEncrypt/Pages/WildcardDomain.php b/web/Modules/LetsEncrypt/Filament/Clusters/LetsEncrypt/Pages/WildcardDomain.php index 2c42875..d6ab84a 100644 --- a/web/Modules/LetsEncrypt/Filament/Clusters/LetsEncrypt/Pages/WildcardDomain.php +++ b/web/Modules/LetsEncrypt/Filament/Clusters/LetsEncrypt/Pages/WildcardDomain.php @@ -52,14 +52,16 @@ class WildcardDomain extends BaseSettings $sslCertificateKeyFilePath = '/root/.acmephp/master/certs/*.'.$domain.'/private/key.private.pem'; $sslCertificateChainFilePath = '/root/.acmephp/master/certs/*.'.$domain.'/public/fullchain.pem'; - $sslCertificateFileContent = file_get_contents($sslCertificateFilePath); - $sslCertificateKeyFileContent = file_get_contents($sslCertificateKeyFilePath); - $sslCertificateChainFileContent = file_get_contents($sslCertificateChainFilePath); - if (file_exists($sslCertificateFilePath) && file_exists($sslCertificateKeyFilePath) && file_exists($sslCertificateChainFilePath)) { + + $sslCertificateFileContent = file_get_contents($sslCertificateFilePath); + $sslCertificateKeyFileContent = file_get_contents($sslCertificateKeyFilePath); + $sslCertificateChainFileContent = file_get_contents($sslCertificateChainFilePath); + + return [ 'sslFiles' => [ 'certificate' => $sslCertificateFilePath, diff --git a/web/app/Models/DomainSslCertificate.php b/web/app/Models/DomainSslCertificate.php index b3dcdf7..89b7009 100644 --- a/web/app/Models/DomainSslCertificate.php +++ b/web/app/Models/DomainSslCertificate.php @@ -23,6 +23,17 @@ class DomainSslCertificate extends Model 'renewed_date', 'renewed_until_date', ]; + public static function boot() + { + parent::boot(); + + static::deleting(function ($model) { + + shell_exec('rm -rf '.'/root/.acmephp/master/certs/'.$model->domain); + shell_exec('rm -rf '.'/etc/letsencrypt/live/'.$model->domain); + + }); + } public function getSSLFiles() {