fix(ssl): remove caCert even if it is a folder by accident
This commit is contained in:
parent
6a52f51851
commit
836006798f
3 changed files with 9 additions and 11 deletions
|
|
@ -20,10 +20,10 @@ public function handle(Server $server)
|
|||
throw new \Exception('Server OS type is not supported for automated installation. Please install Docker manually before continuing: <a target="_blank" class="underline" href="https://coolify.io/docs/installation#manually">documentation</a>.');
|
||||
}
|
||||
|
||||
if (! SslCertificate::where('server_id', $server->id)->exists()) {
|
||||
if (! SslCertificate::where('server_id', $server->server_id)->where('is_ca_certificate', true)->exists()) {
|
||||
$serverCert = SslHelper::generateSslCertificate(
|
||||
commonName: 'Coolify CA Certificate',
|
||||
serverId: $server->id,
|
||||
serverId: $server->server_id,
|
||||
isCaCertificate: true,
|
||||
validityDays: 15 * 365
|
||||
);
|
||||
|
|
@ -33,6 +33,7 @@ public function handle(Server $server)
|
|||
"mkdir -p $caCertPath",
|
||||
"chown -R 9999:root $caCertPath",
|
||||
"chmod -R 700 $caCertPath",
|
||||
"rm -rf $caCertPath/coolify-ca.crt",
|
||||
"echo '{$serverCert->ssl_certificate}' > $caCertPath/coolify-ca.crt",
|
||||
"chmod 644 $caCertPath/coolify-ca.crt",
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -49,10 +49,7 @@ public function mount(string $server_uuid)
|
|||
|
||||
public function loadCaCertificate()
|
||||
{
|
||||
$this->caCertificate = SslCertificate::where('server_id', $this->server->id)
|
||||
->where('resource_type', null)
|
||||
->where('resource_id', null)
|
||||
->first();
|
||||
$this->caCertificate = SslCertificate::where('server_id', $this->server->server_id)->where('is_ca_certificate', true)->first();
|
||||
|
||||
if ($this->caCertificate) {
|
||||
$this->certificateContent = $this->caCertificate->ssl_certificate;
|
||||
|
|
@ -129,7 +126,7 @@ private function writeCertificateToServer()
|
|||
"mkdir -p $caCertPath",
|
||||
"chown -R 9999:root $caCertPath",
|
||||
"chmod -R 700 $caCertPath",
|
||||
"rm -f $caCertPath/coolify-ca.crt",
|
||||
"rm -rf $caCertPath/coolify-ca.crt",
|
||||
"echo '{$this->certificateContent}' > $caCertPath/coolify-ca.crt",
|
||||
"chmod 644 $caCertPath/coolify-ca.crt",
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ public function run()
|
|||
{
|
||||
Server::chunk(200, function ($servers) {
|
||||
foreach ($servers as $server) {
|
||||
$existingCert = SslCertificate::where('server_id', $server->id)->where('is_ca_certificate', true)->first();
|
||||
$existingCaCert = SslCertificate::where('server_id', $server->server_id)->where('is_ca_certificate', true)->first();
|
||||
|
||||
if (! $existingCert) {
|
||||
if (! $existingCaCert) {
|
||||
$caCert = SslHelper::generateSslCertificate(
|
||||
commonName: 'Coolify CA Certificate',
|
||||
serverId: $server->id,
|
||||
|
|
@ -23,7 +23,7 @@ public function run()
|
|||
validityDays: 15 * 365
|
||||
);
|
||||
} else {
|
||||
$caCert = $existingCert;
|
||||
$caCert = $existingCaCert;
|
||||
}
|
||||
$caCertPath = config('constants.coolify.base_config_path').'/ssl/';
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ public function run()
|
|||
"mkdir -p $caCertPath",
|
||||
"chown -R 9999:root $caCertPath",
|
||||
"chmod -R 700 $caCertPath",
|
||||
"rm -f $caCertPath/coolify-ca.crt",
|
||||
"rm -rf $caCertPath/coolify-ca.crt",
|
||||
"echo '{$caCert->ssl_certificate}' > $caCertPath/coolify-ca.crt",
|
||||
"chmod 644 $caCertPath/coolify-ca.crt",
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue