mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-11-04 03:18:49 +03:00
Don't throw error when finding pgp key
This commit is contained in:
parent
7e4733e6d9
commit
fba1ab0c46
3 changed files with 16 additions and 10 deletions
|
|
@ -445,7 +445,13 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
$arguments[] = \escapeshellarg($pattern);
|
||||
}
|
||||
|
||||
$result = $this->exec($arguments);
|
||||
try {
|
||||
$result = $this->exec($arguments);
|
||||
} catch (\RuntimeException $e) {
|
||||
if (!\str_contains($e->getMessage(), 'No public key')) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$keys = [];
|
||||
if ($result) {
|
||||
|
|
@ -565,13 +571,13 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
'private' => []
|
||||
];
|
||||
// Public
|
||||
foreach (($this->keyinfo($pattern) ?: []) as $key) {
|
||||
foreach (($this->keyInfo($pattern) ?: []) as $key) {
|
||||
$key['can_verify'] = $key['can_sign'];
|
||||
unset($key['can_sign']);
|
||||
$keys['public'][] = $key;
|
||||
}
|
||||
// Private, read https://github.com/php-gnupg/php-gnupg/issues/5
|
||||
foreach (($this->keyinfo($pattern, 1) ?: []) as $key) {
|
||||
foreach (($this->keyInfo($pattern, 1) ?: []) as $key) {
|
||||
$key['can_decrypt'] = $key['can_encrypt'];
|
||||
unset($key['can_encrypt']);
|
||||
$keys['private'][] = $key;
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
|
||||
public function keyInfo(string $pattern, bool $private = false): array
|
||||
{
|
||||
return $this->GnuPG->keyinfo($pattern, $private ? 1 : 0);
|
||||
return $this->GnuPG->keyInfo($pattern, $private ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -298,13 +298,13 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
'private' => []
|
||||
];
|
||||
// Public
|
||||
foreach (($this->GnuPG->keyinfo($pattern) ?: []) as $key) {
|
||||
foreach (($this->GnuPG->keyInfo($pattern) ?: []) as $key) {
|
||||
$key['can_verify'] = $key['can_sign'];
|
||||
unset($key['can_sign']);
|
||||
$keys['public'][] = $key;
|
||||
}
|
||||
// Private, read https://github.com/php-gnupg/php-gnupg/issues/5
|
||||
foreach (($this->GnuPG->keyinfo($pattern, 1) ?: []) as $key) {
|
||||
foreach (($this->GnuPG->keyInfo($pattern, 1) ?: []) as $key) {
|
||||
$key['can_decrypt'] = $key['can_encrypt'];
|
||||
unset($key['can_encrypt']);
|
||||
$keys['private'][] = $key;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ abstract class Signature
|
|||
|
||||
private static function importKey($gnupg): void
|
||||
{
|
||||
if (!\count($gnupg->keyinfo(static::KEY_FINGERPRINT))) {
|
||||
if (!\count($gnupg->keyInfo(static::KEY_FINGERPRINT))) {
|
||||
// Try local key
|
||||
$file = __DIR__ . '/repository/releases.asc';
|
||||
if (\is_readable($file)) {
|
||||
|
|
@ -50,16 +50,16 @@ abstract class Signature
|
|||
}
|
||||
$gnupg->importFile($file);
|
||||
}
|
||||
if (!\count($gnupg->keyinfo(static::KEY_FINGERPRINT))) {
|
||||
if (!\count($gnupg->keyInfo(static::KEY_FINGERPRINT))) {
|
||||
// Try to fetch from WKD server
|
||||
// https://snappymail.eu/.well-known/openpgpkey/hu/i4cdqgcarfjdjnba6y4jnf498asg8c6p
|
||||
$sKey = Keyservers::wkd('releases@snappymail.eu');
|
||||
$sKey && $gnupg->import($sKey);
|
||||
// Try to fetch from HKPS server
|
||||
if (!\count($gnupg->keyinfo(static::KEY_FINGERPRINT))) {
|
||||
if (!\count($gnupg->keyInfo(static::KEY_FINGERPRINT))) {
|
||||
$sKey = Keyservers::get(static::KEY_FINGERPRINT);
|
||||
$sKey && $gnupg->import($sKey);
|
||||
if (!\count($gnupg->keyinfo(static::KEY_FINGERPRINT))) {
|
||||
if (!\count($gnupg->keyInfo(static::KEY_FINGERPRINT))) {
|
||||
throw new \Exception('Repository PGP public key is missing');
|
||||
/*
|
||||
$aKeys = Keyservers::index('releases@snappymail.eu');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue