mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-27 19:54:57 +00:00
set password in load methods for each pubkey instead of in loader
This commit is contained in:
parent
5573187f3d
commit
eb659a5544
@ -171,7 +171,10 @@ abstract class AsymmetricKey
|
|||||||
|
|
||||||
$components['format'] = $format;
|
$components['format'] = $format;
|
||||||
|
|
||||||
return static::onLoad($components);
|
$new = static::onLoad($components);
|
||||||
|
return $new instanceof PrivateKey ?
|
||||||
|
$new->withPassword($password) :
|
||||||
|
$new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,7 +202,10 @@ abstract class AsymmetricKey
|
|||||||
|
|
||||||
$components['format'] = $format;
|
$components['format'] = $format;
|
||||||
|
|
||||||
return static::onLoad($components);
|
$new = static::onLoad($components);
|
||||||
|
return $new instanceof PrivateKey ?
|
||||||
|
$new->withPassword($password) :
|
||||||
|
$new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,26 +39,16 @@ abstract class PublicKeyLoader
|
|||||||
public static function load($key, $password = false)
|
public static function load($key, $password = false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$new = EC::load($key, $password);
|
return EC::load($key, $password);
|
||||||
} catch (\Exception $e) {}
|
} catch (NoKeyLoadedException $e) {}
|
||||||
|
|
||||||
if (!isset($new)) {
|
try {
|
||||||
try {
|
return RSA::load($key, $password);
|
||||||
$new = RSA::load($key, $password);
|
} catch (NoKeyLoadedException $e) {}
|
||||||
} catch (\Exception $e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($new)) {
|
try {
|
||||||
try {
|
return DSA::load($key, $password);
|
||||||
$new = DSA::load($key, $password);
|
} catch (NoKeyLoadedException $e) {}
|
||||||
} catch (\Exception $e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($new)) {
|
|
||||||
return $new instanceof PrivateKey ?
|
|
||||||
$new->withPassword($password) :
|
|
||||||
$new;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$x509 = new X509();
|
$x509 = new X509();
|
||||||
|
Loading…
Reference in New Issue
Block a user