/trunk/includes/classes/OIDplus.class.php |
---|
1778,22 → 1778,31 |
} |
/** |
* Returns the private key of the system |
* @param bool $auto_decrypt Try to decrypt the key in case it is encrypted. |
* @return string|false |
* @throws OIDplusException |
*/ |
public static function getSystemPrivateKey() { |
public static function getSystemPrivateKey(bool $auto_decrypt=true) { |
$privKey = OIDplus::config()->getValue('oidplus_private_key'); |
if ($privKey == '') return false; |
if (is_privatekey_encrypted($privKey)) { |
if (!$auto_decrypt) { |
return false; |
} |
$passphrase = self::getPrivKeyPassphrase(); |
if ($passphrase !== false) { |
$privKey = decrypt_private_key($privKey, $passphrase); |
if ($passphrase === false) { |
return false; |
} |
if (is_privatekey_encrypted($privKey)) { |
// This can happen if the key file has vanished |
$privKey = decrypt_private_key($privKey, $passphrase); |
if (($privKey === false) || is_privatekey_encrypted($privKey)) { |
// This can happen if the key file has vanished or decryption failed because of another reason |
return false; |
} |
} |
return $privKey; |
} |
/trunk/includes/classes/OIDplusBaseConfig.class.php |
---|
50,7 → 50,7 |
if ($name == 'SERVER_SECRET') { |
$caller_class = debug_backtrace()[1]['class']; |
if (!str_starts_with($caller_class, 'ViaThinkSoft\\OIDplus\\')) { |
throw new OIDplusException(_L('Outdated plugin: Calling %1 from a plugin is deprecated. Please use %2 instead', 'SERVER_SECRET', 'OIDplus::authUtils()->makeSecret()')); |
throw new OIDplusException(_L('Outdated plugin: Calling %1 from a plugin is deprecated. Please use %2 instead', $name, 'OIDplus::authUtils()->makeSecret()')); |
} |
} |
return $this->exists($name) ? $this->data[$name] : $default; |
/trunk/includes/classes/OIDplusConfig.class.php |
---|
205,6 → 205,19 |
* @throws OIDplusException |
*/ |
public function getValue(string $name, $default=null) { |
if ($name == 'oidplus_private_key') { |
$caller_class = debug_backtrace()[1]['class']; |
if (!str_starts_with($caller_class, 'ViaThinkSoft\\OIDplus\\')) { |
throw new OIDplusException(_L('Outdated plugin: Calling %1 from a plugin is deprecated. Please use %2 instead', $name, 'OIDplus::getSystemPrivateKey()')); |
} |
} |
if ($name == 'oidplus_public_key') { |
$caller_class = debug_backtrace()[1]['class']; |
if (!str_starts_with($caller_class, 'ViaThinkSoft\\OIDplus\\')) { |
throw new OIDplusException(_L('Outdated plugin: Calling %1 from a plugin is deprecated. Please use %2 instead', $name, 'OIDplus::getSystemPublicKey()')); |
} |
} |
// Read all config settings once and write them in array $this->values |
$this->buildConfigArray(); |