An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(ssl): regenerating certs for a specific DB
peaklabs-dev951a454cbcea
diff --git a/app/Livewire/Project/Database/Mariadb/General.php b/app/Livewire/Project/Database/Mariadb/General.phpindex ac6e79140c..63bfd16cde 100644--- a/app/Livewire/Project/Database/Mariadb/General.php+++ b/app/Livewire/Project/Database/Mariadb/General.php@@ -158,10 +158,9 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $server = $this->database->destination->server;-$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)+ ->where('server_id', $this->server->id)->first();if (! $existingCert) {@@ -170,7 +169,10 @@ class General extends Componentreturn;}- $caCert = SslCertificate::where('server_id', $server->id)->firstOrFail();+ $caCertificate = SslCertificate::where('server_id', $this->server->id)+ ->where('resource_type', null)+ ->where('resource_id', null)+ ->first();SslHelper::generateSslCertificate(commonName: $existingCert->common_name,@@ -178,9 +180,10 @@ class General extends ComponentresourceType: $existingCert->resource_type,resourceId: $existingCert->resource_id,serverId: $existingCert->server_id,- caCert: $caCert->ssl_certificate,- caKey: $caCert->ssl_private_key,+ caCert: $caCertificate->ssl_certificate,+ caKey: $caCertificate->ssl_private_key,configurationDir: $existingCert->configuration_dir,+ mountPath: '/var/lib/mysql/certs',);$this->dispatch('success', 'SSL certificates have been regenerated. Please restart the database for changes to take effect.');diff --git a/app/Livewire/Project/Database/Mysql/General.php b/app/Livewire/Project/Database/Mysql/General.phpindex 9ae54e60a0..d7d34c2e1a 100644--- a/app/Livewire/Project/Database/Mysql/General.php+++ b/app/Livewire/Project/Database/Mysql/General.php@@ -158,10 +158,9 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $server = $this->database->destination->server;-$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)+ ->where('server_id', $this->server->id)->first();if (! $existingCert) {@@ -170,7 +169,10 @@ class General extends Componentreturn;}- $caCert = SslCertificate::where('server_id', $server->id)->firstOrFail();+ $caCertificate = SslCertificate::where('server_id', $this->server->id)+ ->where('resource_type', null)+ ->where('resource_id', null)+ ->first();SslHelper::generateSslCertificate(commonName: $existingCert->common_name,@@ -178,9 +180,10 @@ class General extends ComponentresourceType: $existingCert->resource_type,resourceId: $existingCert->resource_id,serverId: $existingCert->server_id,- caCert: $caCert->ssl_certificate,- caKey: $caCert->ssl_private_key,+ caCert: $caCertificate->ssl_certificate,+ caKey: $caCertificate->ssl_private_key,configurationDir: $existingCert->configuration_dir,+ mountPath: '/var/lib/mysql/certs',);$this->dispatch('success', 'SSL certificates have been regenerated. Please restart the database for changes to take effect.');diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.phpindex cb8cefc760..534b66a6d9 100644--- a/app/Livewire/Project/Database/Postgresql/General.php+++ b/app/Livewire/Project/Database/Postgresql/General.php@@ -122,10 +122,9 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $server = $this->database->destination->server;-$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)+ ->where('server_id', $this->server->id)->first();if (! $existingCert) {@@ -134,7 +133,10 @@ class General extends Componentreturn;}- $caCert = SslCertificate::where('server_id', $server->id)->firstOrFail();+ $caCertificate = SslCertificate::where('server_id', $this->server->id)+ ->where('resource_type', null)+ ->where('resource_id', null)+ ->first();SslHelper::generateSslCertificate(commonName: $existingCert->common_name,@@ -142,9 +144,10 @@ class General extends ComponentresourceType: $existingCert->resource_type,resourceId: $existingCert->resource_id,serverId: $existingCert->server_id,- caCert: $caCert->ssl_certificate,- caKey: $caCert->ssl_private_key,+ caCert: $caCertificate->ssl_certificate,+ caKey: $caCertificate->ssl_private_key,configurationDir: $existingCert->configuration_dir,+ mountPath: '/var/lib/postgresql/certs',);$this->dispatch('success', 'SSL certificates have been regenerated. Please restart the database for changes to take effect.');