This commit is contained in:
Bozhidar 2024-08-05 14:19:03 +03:00
parent 76ab0a13c1
commit 0187704576
6 changed files with 23 additions and 10 deletions

View file

@ -3,6 +3,7 @@
namespace Modules\LetsEncrypt\Filament\Clusters\LetsEncrypt\Pages;
use App\ApiClient;
use App\Jobs\ApacheBuild;
use App\MasterDomain;
use App\Models\DomainSslCertificate;
use App\Settings;
@ -49,6 +50,13 @@ class WildcardDomain extends BaseSettings
$masterDomain = new MasterDomain();
$masterDomain->domain = setting('general.wildcard_domain');
$findWildcardSsl = DomainSslCertificate::where('domain', '*.'.$masterDomain->domain)->first();
if ($findWildcardSsl) {
return [
'error' => 'Domain already secured'
];
}
if (file_exists($this->installLogFilePath)) {
unlink($this->installLogFilePath);
}
@ -127,6 +135,8 @@ class WildcardDomain extends BaseSettings
$mds = new MasterDomain();
$mds->configureVirtualHost();
ApacheBuild::dispatchSync();
return [
'success' => 'SSL certificate installed successfully.'
];

View file

@ -56,6 +56,7 @@ Route::post('letsencrypt/secure', function () {
$phyrePHP = ApiClient::getPhyrePHP();
$command = $phyrePHP.' '.$amePHPPharFile.' run '.$findDomain->domain_root.'/acme-config.yaml';
$execSSL = shell_exec($command);
$validateCertificates = [];

View file

@ -62,11 +62,10 @@ class RunRepair extends Command
public function fixApacheErrors()
{
// Rebuild apache config
$apacheBuild = new ApacheBuild();
$apacheBuild->handle();
// $apacheBuild = new ApacheBuild();
// $apacheBuild->handle();
$checkApacheStatus = shell_exec('service apache2 status');
if (strpos($checkApacheStatus, 'Syntax error on line') !== false) {
$apacheErrorLine = null;

View file

@ -3,6 +3,7 @@
namespace app\Http\Controllers\Api;
use App\Http\Controllers\ApiController;
use App\Jobs\ApacheBuild;
use App\Models\Domain;
use App\Models\HostingSubscription;
use Carbon\Carbon;
@ -108,6 +109,8 @@ class DomainsController extends ApiController
$findDomain->save();
ApacheBuild::dispatchSync();
return response()->json([
'status' => 'ok',
'message' => 'Domain updated',

View file

@ -380,30 +380,30 @@ class Domain extends Model
$sslCertificateChainFile = $this->home_root . '/certs/' . $this->domain . '/public/fullchain.pem';
if (!empty($findDomainSSLCertificate->certificate)) {
if (!file_exists($sslCertificateFile)) {
// if (!file_exists($sslCertificateFile)) {
if (!is_dir($this->home_root . '/certs/' . $this->domain . '/public')) {
mkdir($this->home_root . '/certs/' . $this->domain . '/public', 0755, true);
}
file_put_contents($sslCertificateFile, $findDomainSSLCertificate->certificate);
}
// }
}
if (!empty($findDomainSSLCertificate->private_key)) {
if (!file_exists($sslCertificateKeyFile)) {
// if (!file_exists($sslCertificateKeyFile)) {
if (!is_dir($this->home_root . '/certs/' . $this->domain . '/private')) {
mkdir($this->home_root . '/certs/' . $this->domain . '/private', 0755, true);
}
file_put_contents($sslCertificateKeyFile, $findDomainSSLCertificate->private_key);
}
// }
}
if (!empty($findDomainSSLCertificate->certificate_chain)) {
if (!file_exists($sslCertificateChainFile)) {
// if (!file_exists($sslCertificateChainFile)) {
if (!is_dir($this->home_root . '/certs/' . $this->domain . '/public')) {
mkdir($this->home_root . '/certs/' . $this->domain . '/public', 0755, true);
}
file_put_contents($sslCertificateChainFile, $findDomainSSLCertificate->certificate_chain);
}
// }
}
$apacheVirtualHostBuilder->setPort(443);