Skip to content

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.

fix(ssl): ger caCert and `mountPath` correctly

peaklabs-dev62fb2c2877b7
diff --git a/app/Livewire/Project/Database/Mariadb/General.php b/app/Livewire/Project/Database/Mariadb/General.php
index 63bfd16cde..1eda804c98 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 d7d34c2e1a..ad19db2a35 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 534b66a6d9..f5ea25865a 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.');