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(migration): store subjectAlternativeNames as a json array in the db

peaklabs-devfba95c372980
diff --git a/app/Helpers/SslHelper.php b/app/Helpers/SslHelper.php
index 51ac3bffaa..43df8114e7 100644
--- a/app/Helpers/SslHelper.php
+++ b/app/Helpers/SslHelper.php
@@ -107,7 +107,7 @@ class SslHelper
'valid_until' => CarbonImmutable::now()->addDays($validityDays),
'is_ca_certificate' => $isCaCertificate,
'common_name' => $commonName,
- 'subject_alternative_names' => implode(', ', array_merge(["DNS:$commonName"], $subjectAlternativeNames)),
+ 'subject_alternative_names' => $subjectAlternativeNames,
]);
} catch (\Throwable $e) {
throw new \RuntimeException('SSL Certificate generation failed: '.$e->getMessage(), 0, $e);
diff --git a/app/Models/SslCertificate.php b/app/Models/SslCertificate.php
index f1818f9704..54a997dfb5 100644
--- a/app/Models/SslCertificate.php
+++ b/app/Models/SslCertificate.php
@@ -21,6 +21,7 @@ class SslCertificate extends Model
protected $casts = [
'ssl_certificate' => 'encrypted',
'ssl_private_key' => 'encrypted',
+ 'subject_alternative_names' => 'array',
'valid_until' => 'datetime',
];
diff --git a/database/migrations/2025_01_27_153741_create_ssl_certificates_table.php b/database/migrations/2025_01_27_153741_create_ssl_certificates_table.php
index b19493b962..0234820553 100644
--- a/database/migrations/2025_01_27_153741_create_ssl_certificates_table.php
+++ b/database/migrations/2025_01_27_153741_create_ssl_certificates_table.php
@@ -16,7 +16,7 @@ return new class extends Migration
$table->unsignedBigInteger('resource_id')->nullable();
$table->unsignedBigInteger('server_id');
$table->text('common_name');
- $table->text('subject_alternative_names')->nullable();
+ $table->json('subject_alternative_names')->nullable();
$table->timestamp('valid_until');
$table->boolean('is_ca_certificate')->default(false);
$table->timestamps();