coollabsio/coolify · error · Exception
Certificate content cannot be empty.
Error message
Certificate content cannot be empty.
What it means
saveCaCertificate() on a server's CA certificate screen requires a non-empty certificateContent before parsing. The check ! $this->certificateContent is a plain falsy test on the Livewire-bound textarea value, so null, '' (and the degenerate '0') are rejected up front - the save never reaches openssl.
Source
Thrown at app/Livewire/Server/CaCertificate/Show.php:60
$this->caCertificate = $this->server->sslCertificates()->where('is_ca_certificate', true)->first();
if ($this->caCertificate) {
$this->certificateContent = $this->caCertificate->ssl_certificate;
$this->certificateValidUntil = $this->caCertificate->valid_until;
}
}
public function toggleCertificate()
{
$this->showCertificate = ! $this->showCertificate;
}
public function saveCaCertificate()
{
try {
$this->authorize('manageCaCertificate', $this->server);
if (! $this->certificateContent) {
throw new \Exception('Certificate content cannot be empty.');
}
$parsedCert = openssl_x509_read($this->certificateContent);
if (! $parsedCert) {
throw new \Exception('Invalid certificate format.');
}
if (! openssl_x509_export($parsedCert, $cleanedCertificate)) {
throw new \Exception('Failed to process certificate.');
}
$this->certificateContent = $cleanedCertificate;
if ($this->caCertificate) {
$this->caCertificate->ssl_certificate = $this->certificateContent;
$this->caCertificate->save();
$this->loadCaCertificate();
View on GitHub (pinned to 70b9acc424)
Solutions
- Paste the CA certificate (PEM) into the textarea and submit again
- Confirm the textarea is actually bound with wire:model="certificateContent"
- Add a required client-side rule so the button is disabled while empty
- Trim the input; whitespace-only content will trip the format check at line 65 instead
Example fix
// before
public function saveCaCertificate() {
$this->authorize('manageCaCertificate', $this->server);
if (! $this->certificateContent) { throw new \Exception('Certificate content cannot be empty.'); }
}
// after (guard before submit)
if (trim((string) $this->certificateContent) === '') {
$this->dispatch('error', 'Certificate content cannot be empty.');
return;
} Defensive patterns
Strategy: validation
Validate before calling
if (trim((string) $this->certificateContent) === '') {
// block save before calling saveCaCertificate
} Try / catch
Catch \Exception in the action and dispatch('error', $e->getMessage()); note whitespace-only input passes the emptiness check but will fail openssl_x509_read - trim first. Prevention
- Mark the textarea required and disable Save while empty
- Paste full PEM blocks only
- Trim input client-side to avoid whitespace-only submissions
When it happens
Trigger: Clicking Save with an empty textarea; the wire:model property never being filled (form not bound); submitting whitespace-only? (whitespace is truthy, so it passes this check and fails later at openssl_x509_read instead).
Common situations: Misclicks on an empty form; form state reset after a failed previous save; clipboard paste failing silently.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
Related errors
- Invalid Cron / Human expression for Disk Usage Check Frequen
- Invalid certificate format.
- Invalid Cron / Human expression for Docker Cleanup Frequency
- A server with this IP/Domain already exists in your team.
- A server with this IP/Domain is already in use by another te
AI-assisted analysis of coollabsio/coolify@70b9acc424 (2026-08-17).
Data as JSON: /api/errors/9a3b5262f420ff50.
Report an issue: GitHub.