Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions resources/lib/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use UnityWebPortal\lib\exceptions\EncodingUnknownException;
use UnityWebPortal\lib\exceptions\EncodingConversionException;
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Exception\NoKeyLoadedException;

// like assert() but not subject to zend.assertions config
function ensure(bool $condition, ?string $message = null): void
Expand All @@ -16,24 +17,10 @@ function ensure(bool $condition, ?string $message = null): void

function testValidSSHKey(string $key_str): bool
{
// key loader still throws, these just mute warnings for phpunit
// https://github.com/phpseclib/phpseclib/issues/2079
if ($key_str == "") {
return false;
}
// https://github.com/phpseclib/phpseclib/issues/2076
// https://github.com/phpseclib/phpseclib/issues/2077
// there are actually valid JSON keys (JWK), but I don't think anybody uses it
if (!is_null(@json_decode($key_str))) {
return false;
}
try {
PublicKeyLoader::load($key_str);
return true;
// phpseclib should throw only NoKeyLoadedException but that is not the case
// https://github.com/phpseclib/phpseclib/pull/2078
// } catch (\phpseclib3\Exception\NoKeyLoadedException $e) {
} catch (\Throwable $e) {
} catch (NoKeyLoadedException $e) {
return false;
}
}
Expand Down