Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-64723

php curl does not parse certinfo 'Signiture Algorithm' correctly in returned curl data

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.4.7, 3.5.4, 3.6, 3.7
    • Fix Version/s: None
    • Component/s: Administration
    • Labels:
      None
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE

      Description

      If you visit the admin/settings.php?section=mobilesettings page on a moodle site 3.4 or greater that has a valid certificate, moodle will perform a check in admin/tool/mobile/classes/api.php

      if ($cert['Signature Algorithm'] == 'sha1WithRSAEncryption' || $cert['Signature Algorithm'] == 'sha1WithRSA') {

      But you will get a php error notice that the $cert['Signature Algorithm'] index is undefined.

      Notice: Undefined index: Signature Algorithm in /var/www/site/admin/tool/mobile/classes/api.php 
      

      That's because the curl does not parse the returned json data correctly. What we see is

      'Public Key Algorithm' => string(72) "   Signature Algorithm: sha256WithRSAEncryption sha256WithRSAEncryption"

      in the certinfo section of the returned curl data. What we should see is 'Signature Algorithm' having its own element in the associative array, not be part of this string.

       

      To reproduce this error:

      1. Turn on debug display and developer in a moodle site 3.4 or greater.
      2. If on a development site, in the code you can change the line in admin/tool/mobile/classes/api.php

      $curl->head($httpswwwroot . "/$CFG->admin/tool/mobile/mobile.webmanifest.php");
      

      to a site with a valid certificate, eg.

      $curl->head("https://www.google.com");

      3. Load the admin/settings.php?section=mobilesettings page and observe the php notices. Happens in php 5.6, 7.0, 7.2.

      This is not a problem directly in moodle, rather in the way php has implemented curl. But it will produce errors in moodle sites on this page.

      It will be up to php to fix properly, but until then we might want to have a temporary fix in place, or at least be aware of it. I've also made a php bug report: https://bugs.php.net/bug.php?id=77548

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              kristianr Kristian Ringer
              Participants:
              Component watchers:
              Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: