diff --git a/admin/tool/mobile/classes/api.php b/admin/tool/mobile/classes/api.php index 9ea41b0a816..45f0d259851 100644 --- a/admin/tool/mobile/classes/api.php +++ b/admin/tool/mobile/classes/api.php @@ -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: + // Signature Algorithm: . + preg_match('/\s+Signature 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.