mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 22:50:19 +01:00
MDL-64723 tool_mobile: workaround for invalid certificate parsing.
This is to account for specific server configuration that are affected by one of the following issues, which results in certificate signature algorithms being incorrectly parsed: * https://bugs.php.net/bug.php?id=77548 * https://github.com/curl/curl/issues/3706
This commit is contained in:
parent
aed0ee06f9
commit
e5fa5c31d5
@ -603,8 +603,21 @@ class api {
|
||||
$timenow = time();
|
||||
$expectedissuer = null;
|
||||
foreach ($info['certinfo'] as $cert) {
|
||||
|
||||
// Due to a bug in certain curl/openssl versions the signature algorithm isn't always correctly parsed.
|
||||
// See https://github.com/curl/curl/issues/3706 for reference.
|
||||
if (!array_key_exists('Signature Algorithm', $cert)) {
|
||||
// The malformed field that does contain the algorithm we're looking for looks like the following:
|
||||
// <WHITESPACE>Signature Algorithm: <ALGORITHM><CRLF><ALGORITHM>.
|
||||
preg_match('/\s+Signature Algorithm: (?<algorithm>[^\s]+)/', $cert['Public Key Algorithm'], $matches);
|
||||
|
||||
$signaturealgorithm = $matches['algorithm'] ?? '';
|
||||
} else {
|
||||
$signaturealgorithm = $cert['Signature Algorithm'];
|
||||
}
|
||||
|
||||
// Check if the signature algorithm is weak (Android won't work with SHA-1).
|
||||
if ($cert['Signature Algorithm'] == 'sha1WithRSAEncryption' || $cert['Signature Algorithm'] == 'sha1WithRSA') {
|
||||
if ($signaturealgorithm == 'sha1WithRSAEncryption' || $signaturealgorithm == 'sha1WithRSA') {
|
||||
$warnings[] = ['insecurealgorithmwarning', 'tool_mobile'];
|
||||
}
|
||||
// Check certificate start date.
|
||||
|
Loading…
x
Reference in New Issue
Block a user