You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/GLPIKey.php
+45Lines changed: 45 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,51 @@ public function keyExists()
118
118
returnfile_exists($this->keyfile);
119
119
}
120
120
121
+
/**
122
+
* Check if key is valid
123
+
*
124
+
* @return string[]
125
+
*/
126
+
publicfunctiongetKeyFileReadErrors(): array
127
+
{
128
+
$errors = [];
129
+
if (!file_exists($this->keyfile)) {
130
+
$errors[] = sprintf(__s('The security key file does not exist. You have to run the "%s" command to generate a key.'), 'php bin/console security:change_key');
131
+
132
+
return$errors; // early return, as, if file does not exist, no need to check further
133
+
}
134
+
if (false === ($key = @file_get_contents($this->keyfile))) {
135
+
$errors[] = sprintf(__s("Unable to get security key file contents. Fix file permissions of %s."), $this->keyfile);
136
+
137
+
return$errors; // early return, as, if file does not exist, no need to check further
138
+
}
139
+
if (strlen($key) !== SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES) {
140
+
$errors[] = sprintf(__s('Invalid security key file contents. You have to run the "%s" command to regenerate a key.'), 'php bin/console security:change_key');
0 commit comments