coollabsio/coolify · error · RuntimeException

SSL Certificate generation failed: {$e->getMessage()}

Error message

SSL Certificate generation failed: {$e->getMessage()}

What it means

This is the catch-all wrapper at the end of SslHelper::generateSslCertificate(): any Throwable thrown inside the method (private key generation/export, CSR creation, signing, cert export, temp-file handling) is rethrown as a RuntimeException prefixed 'SSL Certificate generation failed:'. The suffix is the underlying exception message — that is the real error to diagnose.

Source

Thrown at app/Helpers/SslHelper.php:228

                        'resource_type' => $resourceType,
                        'resource_id' => $resourceId,
                    ]);

                    $model->fileStorages()->create([
                        'fs_path' => $configurationDir.'/ssl/server.key',
                        'mount_path' => $mountPath.'/server.key',
                        'content' => $privateKeyStr,
                        'is_directory' => false,
                        'chmod' => '600',
                        'resource_type' => $resourceType,
                        'resource_id' => $resourceId,
                    ]);
                }
            }

            return $sslCertificate;
        } catch (\Throwable $e) {
            throw new \RuntimeException('SSL Certificate generation failed: '.$e->getMessage(), 0, $e);
        } finally {
            fclose($tempConfig);
        }
    }
}

View on GitHub (pinned to 70b9acc424)

Solutions

  1. Read the text after 'SSL Certificate generation failed:' — it names the exact failing step (key, CSR, signing, export) and the OpenSSL error string.
  2. Fix the underlying cause using the guidance for that inner error (extension/config/CA pair).
  3. Verify environment basics: OpenSSL extension loaded, openssl.cnf readable, /tmp writable, disk space available.

Example fix

// before: only the wrapper message surfaces
try {
    SslHelper::generateSslCertificate($commonName);
} catch (\RuntimeException $e) {
    log($e->getMessage()); // 'SSL Certificate generation failed: Failed to generate CSR: ...'
}

// after: log the previous exception chain for the real cause
catch (\RuntimeException $e) {
    while ($e) {
        log($e->getMessage());
        $e = $e->getPrevious();
    }
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    $cert = SslHelper::generateSslCertificate($commonName, $sans);
} catch (\RuntimeException $e) {
    // unwrap the chain: the innermost message is the real cause
    $cause = $e;
    while ($cause->getPrevious()) {
        $cause = $cause->getPrevious();
    }
    report("SSL generation failed: {$cause->getMessage()}");
    return null; // fall back to existing certificate if present
}

Prevention

When it happens

Trigger: Any failure during certificate issuance: the OpenSSL key/CSR/sign/export errors from this helper, temp config file write failures, or SslCertificate model persistence errors. Triggered whenever Coolify generates certificates for resources (e.g. enabling SSL on a service/app).

Common situations: Misconfigured OpenSSL in the PHP runtime (see the specific inner errors); full disk preventing temp config creation; invalid CA inputs when issuing CA-signed certificates.

Understand the failure class

Related errors


AI-assisted analysis of coollabsio/coolify@70b9acc424 (2026-08-17). Data as JSON: /api/errors/7305b0cf864ecc99. Report an issue: GitHub.