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

Deprecated openssl_x509_free(), openssl_pkey_free() and openssl_free_key()

    XMLWordPrintable

Details

    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE
    • MDL-73523_311
    • Hide
      1. Sanity check, just verify that the solution provided is acceptable and correct (enclosing the deprecated function calls within condition.
      2. Sanity check, confirm that all the current cases of openssl_x509_free(), openssl_pkey_free() and openssl_free_key()) in codebase are now "protected" with the agreed condition
      3. Leave this under CiBoT hands, at very least it will detect if there is any PHP problem with the code, although I don't think that the modified code us covered at all (or it would have been emitting deprecation warnings since long ago).
      Show
      Sanity check, just verify that the solution provided is acceptable and correct (enclosing the deprecated function calls within condition. Sanity check, confirm that all the current cases of openssl_x509_free() , openssl_pkey_free() and openssl_free_key() ) in codebase are now "protected" with the agreed condition Leave this under CiBoT hands, at very least it will detect if there is any PHP problem with the code, although I don't think that the modified code us covered at all (or it would have been emitting deprecation warnings since long ago).

    Description

      From the php80 release notes:

      . The openssl_x509_free() function is deprecated and no longer has an effect,
      instead the OpenSSLCertificate instance is automatically destroyed if it is no
      longer referenced.
      . The openssl_pkey_free() (and its alias openssl_free_key)
      function is deprecated and no longer has an effect,
      instead the OpenSSLAsymmetricKey instance is automatically destroyed if it is no
      longer referenced.

      So this issue is about to verify that all the uses in code are conditional (for php < 8).

      Cases:

      $ ag '(openssl_x509_free|openssl_pkey_free|openssl_free_key)'
      repository/s3/S3.php
      354:			openssl_free_key(self::$__signingKeyResource);
       
      enrol/lti/ims-blti/OAuth.php
      152:    openssl_free_key($privatekeyid);
      172:    openssl_free_key($publickeyid);
       
      mnet/lib.php
      425:    openssl_x509_free($selfSignedCert);
      434:    openssl_pkey_free($new_key);
       
      lib/phpmailer/src/PHPMailer.php
      4530:                openssl_pkey_free($privKey);
      4536:            openssl_pkey_free($privKey);
       
      lib/google/src/Google/Signer/P12.php
      77:      openssl_pkey_free($this->privateKey);
       
      lib/google/src/Google/Verifier/Pem.php
      53:      openssl_x509_free($this->publicKey);
       
      mod/lti/OAuth.php
      266:        openssl_free_key($privatekeyid);
      286:        openssl_free_key($publickeyid);
      

      The changes will be performed similar to what PHPMailer is already doing, for example:

      -        // Release the key resource
      -        openssl_free_key($publickeyid);
      +        // TODO: Remove this block once PHP 8.0 becomes required.
      +        if (PHP_MAJOR_VERSION < 8) {
      +            // Release the key resource
      +            openssl_free_key($publickeyid);
      +        }
      

      Attachments

        Issue Links

          Activity

            People

              stronk7 Eloy Lafuente (stronk7)
              stronk7 Eloy Lafuente (stronk7)
              Huong Nguyen Huong Nguyen
              Jun Pataleta Jun Pataleta
              CiBoT CiBoT
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona), Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Sujith Haridasan, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                14/Mar/22

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 3 minutes
                  3h 3m