fix: add public key attribute to privatekey model
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user