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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat/fix(ssl): fix some issues and improve ssl generation helper
peaklabs-dev6eabfd5c8e4e
diff --git a/app/Helpers/SslHelper.php b/app/Helpers/SslHelper.phpindex 9559763660..440815b80a 100644--- a/app/Helpers/SslHelper.php+++ b/app/Helpers/SslHelper.php@@ -10,7 +10,7 @@ class SslHelper{private const DEFAULT_ORGANIZATION_NAME = 'Coolify';- private const DEFAULT_COUNTRY_NAME = 'ZZ';+ private const DEFAULT_COUNTRY_NAME = 'XX';private const DEFAULT_STATE_NAME = 'Default';@@ -50,55 +50,65 @@ class SslHelperif ($server) {$ip = $server->getIp;if ($ip) {- if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) {- $subjectAlternativeNames[] = "IP:$ip";- } else {- $subjectAlternativeNames[] = "DNS:$ip";- }+ $type = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)+ ? 'IP'+ : 'DNS';+ $subjectAlternativeNames = array_unique(+ array_merge($subjectAlternativeNames, ["$type:$ip"])+ );}}}- $subjectAlternativeNames = array_unique(- array_merge(["DNS:$commonName"], $subjectAlternativeNames)- );+ $basicConstraints = $isCaCertificate ? 'critical, CA:TRUE, pathlen:0' : 'critical, CA:FALSE';+ $keyUsage = $isCaCertificate ? 'critical, keyCertSign, cRLSign' : 'critical, digitalSignature, keyAgreement';- $formattedSubjectAltNames = [];- foreach ($subjectAlternativeNames as $index => $san) {- [$type, $value] = explode(':', $san, 2);- $formattedSubjectAltNames[] = "{$type}.".($index + 1)." = $value";- }- $formattedSubjectAltNamesSection = implode("\n", $formattedSubjectAltNames);+ $subjectAltNameSection = '';+ $extendedKeyUsageSection = '';- $basicConstraints = $isCaCertificate ? 'critical, CA:TRUE, pathlen:0' : 'critical, CA:FALSE';- $keyUsage = $isCaCertificate ? 'critical, keyCertSign, cRLSign' : 'critical, digitalSignature';- $authorityKeyIdentifierLine = $isCaCertificate ? '' : "authorityKeyIdentifier = critical,keyid,issuer\n";+ if (! $isCaCertificate) {+ $extendedKeyUsageSection = "\nextendedKeyUsage = serverAuth";++ $subjectAlternativeNames = array_values(+ array_unique(+ array_merge(["DNS:$commonName"], $subjectAlternativeNames)+ )+ );++ $formattedSubjectAltNames = array_map(+ function ($index, $san) {+ [$type, $value] = explode(':', $san, 2);++ return "{$type}.".($index + 1)." = $value";+ },+ array_keys($subjectAlternativeNames),+ $subjectAlternativeNames+ );++ $subjectAltNameSection = "subjectAltName = @subject_alt_names\n\n[ subject_alt_names ]\n"+ .implode("\n", $formattedSubjectAltNames);+ }$config = <<<CONF- [req]+ [ req ]prompt = nodistinguished_name = distinguished_namereq_extensions = req_ext- [distinguished_name]- C = $countryName- ST = $stateName- O = $organizationName+ [ distinguished_name ]CN = $commonName-- [req_ext]++ [ req_ext ]basicConstraints = $basicConstraintskeyUsage = $keyUsage+ {$extendedKeyUsageSection}- [v3_req]+ [ v3_req ]basicConstraints = $basicConstraintskeyUsage = $keyUsage- subjectKeyIdentifier = critical,hash- {$authorityKeyIdentifierLine}- subjectAltName = critical,@subject_alt_names-- [subject_alt_names]- $formattedSubjectAltNamesSection+ {$extendedKeyUsageSection}+ subjectKeyIdentifier = hash+ {$subjectAltNameSection}CONF;$tempConfig = tmpfile();