feat(ssl): new modes for MongoDB and get caCert and mountPath correctly

This commit is contained in:
peaklabs-dev
2025-02-07 18:31:41 +01:00
parent 8a45c24dc2
commit bd33f65c0a
2 changed files with 10 additions and 13 deletions

View File

@@ -39,7 +39,7 @@ class General extends Component
'database.is_log_drain_enabled' => 'nullable|boolean', 'database.is_log_drain_enabled' => 'nullable|boolean',
'database.custom_docker_run_options' => 'nullable', 'database.custom_docker_run_options' => 'nullable',
'database.enable_ssl' => 'boolean', 'database.enable_ssl' => 'boolean',
'database.ssl_mode' => 'nullable|string|in:allowSSL,preferSSL,requireSSL,verifyCA,verifyFull', 'database.ssl_mode' => 'nullable|string|in:allow,prefer,require,verify-ca,verify-full',
]; ];
protected $validationAttributes = [ protected $validationAttributes = [
@@ -170,10 +170,7 @@ class General extends Component
return; return;
} }
$caCertificate = SslCertificate::where('server_id', $this->server->id) $caCert = SslCertificate::where('server_id', $existingCert->server_id)->where('is_ca_certificate', true)->first();
->where('resource_type', null)
->where('resource_id', null)
->first();
SslHelper::generateSslCertificate( SslHelper::generateSslCertificate(
commonName: $existingCert->common_name, commonName: $existingCert->common_name,
@@ -181,10 +178,10 @@ class General extends Component
resourceType: $existingCert->resource_type, resourceType: $existingCert->resource_type,
resourceId: $existingCert->resource_id, resourceId: $existingCert->resource_id,
serverId: $existingCert->server_id, serverId: $existingCert->server_id,
caCert: $caCertificate->ssl_certificate, caCert: $caCert->ssl_certificate,
caKey: $caCertificate->ssl_private_key, caKey: $caCert->ssl_private_key,
configurationDir: $existingCert->configuration_dir, configurationDir: $existingCert->configuration_dir,
mountPath: '/etc/mongo/certs', mountPath: $existingCert->mount_path,
); );
$this->dispatch('success', 'SSL certificates have been regenerated. Please restart the database for changes to take effect.'); $this->dispatch('success', 'SSL certificates have been regenerated. Please restart the database for changes to take effect.');

View File

@@ -92,11 +92,11 @@
<x-forms.select id="database.ssl_mode" label="SSL Mode" <x-forms.select id="database.ssl_mode" label="SSL Mode"
wire:model.live="database.ssl_mode" instantSave="instantSaveSSL" wire:model.live="database.ssl_mode" instantSave="instantSaveSSL"
helper="Choose the SSL verification mode for MongoDB connections"> helper="Choose the SSL verification mode for MongoDB connections">
<option value="allowSSL">allowSSL</option> <option value="allow">allow</option>
<option value="preferSSL">preferSSL</option> <option value="prefer">prefer</option>
<option value="requireSSL">requireSSL</option> <option value="require">require</option>
<option value="verifyCA">verifyCA</option> <option value="verify-ca">verify-ca</option>
<option value="verifyFull">verifyFull</option> <option value="verify-full">verify-full</option>
</x-forms.select> </x-forms.select>
@endif @endif
</div> </div>