Moodle
  1. Moodle
  2. MDL-13503

Moodle Networking: cannot find openssl.cnf so networking fails.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9.6
    • Component/s: MNet
    • Labels:
      None
    • Environment:
      Confirmed on both Windows and Linux platforms including with fresh installs
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      30549

      Description

      When going through the Site Administration tree in the latest CVS and with server Debug messages set to normal, most items of the Networking branch give several warnings of the form below that are within the function mnet_generate_keypair. We don't use this form of networking yet, so I am unable to fully understand the problem, but it appears that the keypair is not being generated. And the admin block should not be giving warnings under normal initial install situations. There have been several changes to these files in the past 5 days, so perhaps an issue got introduced.

      Here are the messages:

      Warning: openssl_csr_sign() [function.openssl-csr-sign]: cannot get CSR from parameter 1 in /var/www/moodle/mnet/lib.php on line 323

      Warning: openssl_x509_export() [function.openssl-x509-export]: cannot get cert from parameter 1 in /var/www/moodle/mnet/lib.php on line 327

      Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in /var/www/moodle/mnet/lib.php on line 328

      Warning: openssl_pkey_export() [function.openssl-pkey-export]: cannot get key from parameter 1 in /var/www/moodle/mnet/lib.php on line 332

      Warning: openssl_pkey_free() expects parameter 1 to be resource, boolean given in /var/www/moodle/mnet/lib.php on line 333

        Activity

        Hide
        Scott Provost added a comment -

        This is more than a minor issue. It breaks moodle networking on all installations that haven't paid for technical support.
        This essentially makes Moodle commercial software with a free dysfunctional version.

        Show
        Scott Provost added a comment - This is more than a minor issue. It breaks moodle networking on all installations that haven't paid for technical support. This essentially makes Moodle commercial software with a free dysfunctional version.
        Hide
        Mark Stevens added a comment -

        I agree with Scott, not minor at all. Code not pointing to the right place for the openSSL.conf file. Hard coding the file location as thierry duvert posted in: http://moodle.org/mod/forum/discuss.php?d=110343 fixes this. Here is what he posted:

        in /mnet/lib.php

        i replaced

        $new_key = openssl_pkey_new();
        $csr_rsc = openssl_csr_new($dn, $new_key, array('private_key_bits',2048));
        $selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days);

        by (replace by your path to openssl.cnf)

        $config = array(
        "config" => "C:/wamp/bin/apache/Apache2.2.9/conf/openssl.cnf"
        );

        $new_key = openssl_pkey_new($config);
        $csr_rsc = openssl_csr_new($dn, $new_key, $config);
        $selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days, $config);

        Show
        Mark Stevens added a comment - I agree with Scott, not minor at all. Code not pointing to the right place for the openSSL.conf file. Hard coding the file location as thierry duvert posted in: http://moodle.org/mod/forum/discuss.php?d=110343 fixes this. Here is what he posted: in /mnet/lib.php i replaced $new_key = openssl_pkey_new(); $csr_rsc = openssl_csr_new($dn, $new_key, array('private_key_bits',2048)); $selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days); by (replace by your path to openssl.cnf) $config = array( "config" => "C:/wamp/bin/apache/Apache2.2.9/conf/openssl.cnf" ); $new_key = openssl_pkey_new($config); $csr_rsc = openssl_csr_new($dn, $new_key, $config); $selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days, $config);
        Hide
        Dan Marsden added a comment -

        I've been looking at this issue this week trying to get Moodle Networking under Windows to work using a Xamp installer package - this is also an issue on the Mahara side and I have a patch ready to go into Mahara core to fix it there as well.

        as mentioned in the bug - this occurs when PHP cannot find the openssl.cnf file - and for some reason, setting the Windows Environment settings doesn't always work to allow it to be found - also relying on environment vars is a pain if you are using something like MoWeS or a XAMPP installer.

        the attached patch allows the path to the openssl.cnf to be set in config.php which is more reliable.

        Show
        Dan Marsden added a comment - I've been looking at this issue this week trying to get Moodle Networking under Windows to work using a Xamp installer package - this is also an issue on the Mahara side and I have a patch ready to go into Mahara core to fix it there as well. as mentioned in the bug - this occurs when PHP cannot find the openssl.cnf file - and for some reason, setting the Windows Environment settings doesn't always work to allow it to be found - also relying on environment vars is a pain if you are using something like MoWeS or a XAMPP installer. the attached patch allows the path to the openssl.cnf to be set in config.php which is more reliable.
        Hide
        Petr Škoda added a comment -

        +1 for commit into STABLE, thanks

        Show
        Petr Škoda added a comment - +1 for commit into STABLE, thanks
        Hide
        Dan Marsden added a comment -

        fix now in 1.9Stable and Head,

        I've tidied the Mnet FAQ's a little and added an item to explain how to use the new code here:
        http://docs.moodle.org/en/Moodle_Network_FAQ#Moodle_doesn.27t_generate_any_keys_on_the_networking_pages

        thanks for the report!

        Show
        Dan Marsden added a comment - fix now in 1.9Stable and Head, I've tidied the Mnet FAQ's a little and added an item to explain how to use the new code here: http://docs.moodle.org/en/Moodle_Network_FAQ#Moodle_doesn.27t_generate_any_keys_on_the_networking_pages thanks for the report!
        Hide
        miki Alliel added a comment -

        Setting $CFG->opensslcnf = 'C:/apache2/bin/openssl.cnf'; or on IIS
        $CFG->opensslcnf = 'C:\PHP\extras\openssl\openssl.cnf;
        ON config.php file

        worked for me
        thanks dan

        Show
        miki Alliel added a comment - Setting $CFG->opensslcnf = 'C:/apache2/bin/openssl.cnf'; or on IIS $CFG->opensslcnf = 'C:\PHP\extras\openssl\openssl.cnf; ON config.php file worked for me thanks dan

          People

          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: