diff --git a/app/Livewire/Project/Database/Mariadb/General.php b/app/Livewire/Project/Database/Mariadb/General.php index 63bfd16cd..1eda804c9 100644 --- a/app/Livewire/Project/Database/Mariadb/General.php +++ b/app/Livewire/Project/Database/Mariadb/General.php @@ -169,10 +169,7 @@ class General extends Component return; } - $caCertificate = SslCertificate::where('server_id', $this->server->id) - ->where('resource_type', null) - ->where('resource_id', null) - ->first(); + $caCert = SslCertificate::where('server_id', $existingCert->server_id)->where('is_ca_certificate', true)->first(); SslHelper::generateSslCertificate( commonName: $existingCert->common_name, @@ -180,10 +177,10 @@ class General extends Component resourceType: $existingCert->resource_type, resourceId: $existingCert->resource_id, serverId: $existingCert->server_id, - caCert: $caCertificate->ssl_certificate, - caKey: $caCertificate->ssl_private_key, + caCert: $caCert->ssl_certificate, + caKey: $caCert->ssl_private_key, configurationDir: $existingCert->configuration_dir, - mountPath: '/var/lib/mysql/certs', + mountPath: $existingCert->mount_path, ); $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.php index d7d34c2e1..ad19db2a3 100644 --- a/app/Livewire/Project/Database/Mysql/General.php +++ b/app/Livewire/Project/Database/Mysql/General.php @@ -169,10 +169,7 @@ class General extends Component return; } - $caCertificate = SslCertificate::where('server_id', $this->server->id) - ->where('resource_type', null) - ->where('resource_id', null) - ->first(); + $caCert = SslCertificate::where('server_id', $existingCert->server_id)->where('is_ca_certificate', true)->first(); SslHelper::generateSslCertificate( commonName: $existingCert->common_name, @@ -180,10 +177,10 @@ class General extends Component resourceType: $existingCert->resource_type, resourceId: $existingCert->resource_id, serverId: $existingCert->server_id, - caCert: $caCertificate->ssl_certificate, - caKey: $caCertificate->ssl_private_key, + caCert: $caCert->ssl_certificate, + caKey: $caCert->ssl_private_key, configurationDir: $existingCert->configuration_dir, - mountPath: '/var/lib/mysql/certs', + mountPath: $existingCert->mount_path, ); $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.php index 534b66a6d..f5ea25865 100644 --- a/app/Livewire/Project/Database/Postgresql/General.php +++ b/app/Livewire/Project/Database/Postgresql/General.php @@ -133,10 +133,7 @@ class General extends Component return; } - $caCertificate = SslCertificate::where('server_id', $this->server->id) - ->where('resource_type', null) - ->where('resource_id', null) - ->first(); + $caCert = SslCertificate::where('server_id', $existingCert->server_id)->where('is_ca_certificate', true)->first(); SslHelper::generateSslCertificate( commonName: $existingCert->common_name, @@ -144,10 +141,10 @@ class General extends Component resourceType: $existingCert->resource_type, resourceId: $existingCert->resource_id, serverId: $existingCert->server_id, - caCert: $caCertificate->ssl_certificate, - caKey: $caCertificate->ssl_private_key, + caCert: $caCert->ssl_certificate, + caKey: $caCert->ssl_private_key, configurationDir: $existingCert->configuration_dir, - mountPath: '/var/lib/postgresql/certs', + mountPath: $existingCert->mount_path, ); $this->dispatch('success', 'SSL certificates have been regenerated. Please restart the database for changes to take effect.');