'integer', 'certificate' => 'encrypted', 'pk' => 'encrypted', 'ca' => 'encrypted', 'expires_at' => 'datetime', ]; public function site(): BelongsTo { return $this->belongsTo(Site::class); } public function getCertsDirectoryPath(): ?string { if ($this->type == 'letsencrypt') { return '/etc/letsencrypt/live/'.$this->site->domain; } if ($this->type == 'custom') { return '/etc/ssl/'.$this->site->domain; } return ''; } public function getCertificatePath(): ?string { if ($this->type == 'letsencrypt') { return $this->certificate; } if ($this->type == 'custom') { return $this->getCertsDirectoryPath().'/cert.pem'; } return ''; } public function getPkPath(): ?string { if ($this->type == 'letsencrypt') { return $this->pk; } if ($this->type == 'custom') { return $this->getCertsDirectoryPath().'/privkey.pem'; } return ''; } public function getCaPath(): ?string { if ($this->type == 'letsencrypt') { return $this->ca; } if ($this->type == 'custom') { return $this->getCertsDirectoryPath().'/fullchain.pem'; } return ''; } public function validateSetup(string $result): bool { if (! Str::contains($result, 'Successfully received certificate')) { return false; } if ($this->type == 'letsencrypt') { $this->certificate = $this->getCertsDirectoryPath().'/fullchain.pem'; $this->pk = $this->getCertsDirectoryPath().'/privkey.pem'; $this->save(); } return true; } }