{"record":{"id":"9a3b5262f420ff50","repo":"coollabsio/coolify","slug":"certificate-content-cannot-be-empty","errorCode":null,"errorMessage":"Certificate content cannot be empty.","messagePattern":"Certificate content cannot be empty\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"app/Livewire/Server/CaCertificate/Show.php","lineNumber":60,"sourceCode":"        $this->caCertificate = $this->server->sslCertificates()->where('is_ca_certificate', true)->first();\n\n        if ($this->caCertificate) {\n            $this->certificateContent = $this->caCertificate->ssl_certificate;\n            $this->certificateValidUntil = $this->caCertificate->valid_until;\n        }\n    }\n\n    public function toggleCertificate()\n    {\n        $this->showCertificate = ! $this->showCertificate;\n    }\n\n    public function saveCaCertificate()\n    {\n        try {\n            $this->authorize('manageCaCertificate', $this->server);\n            if (! $this->certificateContent) {\n                throw new \\Exception('Certificate content cannot be empty.');\n            }\n\n            $parsedCert = openssl_x509_read($this->certificateContent);\n            if (! $parsedCert) {\n                throw new \\Exception('Invalid certificate format.');\n            }\n\n            if (! openssl_x509_export($parsedCert, $cleanedCertificate)) {\n                throw new \\Exception('Failed to process certificate.');\n            }\n            $this->certificateContent = $cleanedCertificate;\n\n            if ($this->caCertificate) {\n                $this->caCertificate->ssl_certificate = $this->certificateContent;\n                $this->caCertificate->save();\n\n                $this->loadCaCertificate();\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/coollabsio/coolify/blob/70b9acc42467278373e00de77abb40684e25b395/app/Livewire/Server/CaCertificate/Show.php#L42-L78","documentation":"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.","triggerScenarios":"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).","commonSituations":"Misclicks on an empty form; form state reset after a failed previous save; clipboard paste failing silently.","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"],"exampleFix":"// before\npublic function saveCaCertificate() {\n    $this->authorize('manageCaCertificate', $this->server);\n    if (! $this->certificateContent) { throw new \\Exception('Certificate content cannot be empty.'); }\n}\n\n// after (guard before submit)\nif (trim((string) $this->certificateContent) === '') {\n    $this->dispatch('error', 'Certificate content cannot be empty.');\n    return;\n}","handlingStrategy":"validation","validationCode":"if (trim((string) $this->certificateContent) === '') {\n    // block save before calling saveCaCertificate\n}","typeGuard":null,"tryCatchPattern":"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.","preventionTips":["Mark the textarea required and disable Save while empty","Paste full PEM blocks only","Trim input client-side to avoid whitespace-only submissions"],"tags":["certificate","ca","validation","server"],"backgroundTag":"empty-required-field","analyzedSha":"70b9acc42467278373e00de77abb40684e25b395","analyzedAt":"2026-08-17T01:41:01.313Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}