Skip to content

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.

fix: add public key attribute to privatekey model

Andras Bacsaic891102db664
diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php
index 80015d87f8..0e702e4602 100644
--- a/app/Models/PrivateKey.php
+++ b/app/Models/PrivateKey.php
@@ -40,6 +40,8 @@ class PrivateKey extends BaseModel
'private_key' => 'encrypted',
];
+ protected $appends = ['public_key'];
+
protected static function booted()
{
static::saving(function ($key) {
@@ -64,6 +66,11 @@ class PrivateKey extends BaseModel
});
}
+ public function getPublicKeyAttribute()
+ {
+ return self::extractPublicKeyFromPrivate($this->private_key) ?? 'Error loading private key';
+ }
+
public function getPublicKey()
{
return self::extractPublicKeyFromPrivate($this->private_key) ?? 'Error loading private key';
@@ -208,15 +215,14 @@ class PrivateKey extends BaseModel
{
try {
$key = PublicKeyLoader::load($privateKey);
- $publicKey = $key->getPublicKey();
- return $publicKey->getFingerprint('sha256');
+ return $key->getPublicKey()->getFingerprint('sha256');
} catch (\Throwable $e) {
return null;
}
}
- private static function fingerprintExists($fingerprint, $excludeId = null)
+ public static function fingerprintExists($fingerprint, $excludeId = null)
{
$query = self::query()
->where('fingerprint', $fingerprint)