ExternalFeed block cron task fails when SSL cert is not valid for a feed

Bug #1773864 reported by Ghada El-Zoghbi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Ghada El-Zoghbi
17.04
Fix Released
High
Unassigned
17.10
Fix Released
High
Unassigned
18.04
Fix Released
High
Unassigned
18.10
Fix Released
High
Ghada El-Zoghbi

Bug Description

Mahara: 18.04
OS: Linux
DB: Postgres
Browser: n/a

Cron fails (and is therefore locked) when one of the rss feeds has an invalid ssl certificate.

The cron job calls lib/web.php::mahara_http_request() from blocktype/externalfeed/lib.php::parse_feed()

The following error results:

[WAR] 63 (lib/web.php:4425) Curl error: 60: SSL certificate problem: unable to get local issuer certificate
Call stack (most recent first):
  * log_message("Curl error: 60: SSL certificate problem: unable to...", 8, true, true) at /var/www/mahara/htdocs/lib/errors.php:95
  * log_warn("Curl error: 60: SSL certificate problem: unable to...") at /var/www/mahara/htdocs/lib/web.php:4425
  * mahara_http_request(array(size 3), false) at /var/www/mahara/htdocs/blocktype/externalfeed/lib.php:421
  * PluginBlocktypeExternalfeed::parse_feed("http://www.safeworkaustralia.gov.au/sites/SWA/medi...", "0", "", "********") at /var/www/mahara/htdocs/blocktype/externalfeed/lib.php:336
  * PluginBlocktypeExternalfeed::refresh_feeds() at /var/www/mahara/htdocs/lib/mahara.php:1809
  * call_static_method("PluginBlocktypeExternalfeed", "refresh_feeds") at /var/www/mahara/htdocs/lib/cron.php:115

[WAR] 63 (blocktype/externalfeed/lib.php:336) error in /blocktype/externalfeed/lib.php line 428. error:SSL certificate problem: unable to get local issuer certificate
[WAR] 63 (lib/errors.php:536) [Error]: Wrong parameters for MaharaException([string $message [, long $code [, Throwable $previous = NULL]]])
Call stack (most recent first):
  * exception(object(Error)) at Unknown:0

I had added extra debugging statements to see the error:

[WAR] 63 (blocktype/externalfeed/lib.php:336) error in /blocktype/externalfeed/lib.php line 428. error:SSL certificate problem: unable to get local issuer certificate

Mahara then raises a MaharaException with the error (SSL certificate problem: unable to get local issuer certificate) as the code. But, it's not an integer so it fails with:

[WAR] 63 (lib/errors.php:536) [Error]: Wrong parameters for MaharaException([string $message [, long $code [, Throwable $previous = NULL]]])

We need to check if the error coming back is a number or string. If number, pass it as the code in the MaharaException. Otherwise, append it to the text of the error message so the data is not lost.

We found this when upgrading from 17.04 to 18.04. This issue is present in 17.04 as well.

Revision history for this message
Ghada El-Zoghbi (ghada-z) wrote :

To reproduce:

* Create a page
* Add External Feed:
** Feed Location = http://www.safeworkaustralia.gov.au/sites/SWA/mediafeed (at time of post)
** Insecure SSL mode = No
** Save

These other feeds were causing issues at time of this post:

* http://www.safeworkaustralia.gov.au/sites/SWA/publicationfeed
* http://www.safeworkaustralia.gov.au/sites/SWA/newsfeed

In the cron log, error should appear and externalfeed cron task should now be locked (when it runs and it's time to refresh the feed).

To speed up testing:

* in blocltype/externalfeed/lib.php::refresh_feeds - set in the sql query to refresh every 0 minutes (instead of 30 minutes).

* in blocltype/externalfeed/lib.php::parse_feeds - comment out the 'throw $cache[$source]' and the 'return $cache[$source]' at the top of the function.

* change cron time for the task to run every minute:
update blocktype_cron set minute = '*', nextrun = '2018-05-29 11:54' where callfunction = 'refresh_feeds';

If feeds are now valid, can try to set $result->error after the mahara_http_request() call in the parse_feed() function.

i.e. $result->error = "SSL certificate problem: unable to get local issuer certificate";

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/8906

Changed in mahara:
assignee: nobody → Ghada El-Zoghbi (ghada-z)
Changed in mahara:
importance: Undecided → Medium
status: New → In Progress
milestone: none → 18.10.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/8906
Committed: https://git.mahara.org/mahara/mahara/commit/23287554e3c3d5398c118583e60de1cab8fabc36
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 23287554e3c3d5398c118583e60de1cab8fabc36
Author: Ghada El-Zoghbi <email address hidden>
Date: Tue May 29 13:50:13 2018 +1000

Bug 1773864: Throw MaharaException with valid error number

Pass error number and message correctly to the
MaharaException call when coming back from the
externalfeed curl call.

Sponsored by Central Queensland University

behatnotneeded

Change-Id: I03a2b666bde3905d2466ffbe35f1b35ca8a088bf

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "18.04_STABLE" branch: https://reviews.mahara.org/8934

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "17.10_STABLE" branch: https://reviews.mahara.org/8935

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "17.04_STABLE" branch: https://reviews.mahara.org/8936

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/8934
Committed: https://git.mahara.org/mahara/mahara/commit/afb543fa78208f2dbf6ddd2e0cba8c632c733c16
Submitter: Robert Lyon (<email address hidden>)
Branch: 18.04_STABLE

commit afb543fa78208f2dbf6ddd2e0cba8c632c733c16
Author: Ghada El-Zoghbi <email address hidden>
Date: Tue May 29 13:50:13 2018 +1000

Bug 1773864: Throw MaharaException with valid error number

Pass error number and message correctly to the
MaharaException call when coming back from the
externalfeed curl call.

Sponsored by Central Queensland University

behatnotneeded

Change-Id: I03a2b666bde3905d2466ffbe35f1b35ca8a088bf
(cherry picked from commit 23287554e3c3d5398c118583e60de1cab8fabc36)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/8935
Committed: https://git.mahara.org/mahara/mahara/commit/263eb365f89ade5b073a12c9a009a8b0553506c9
Submitter: Robert Lyon (<email address hidden>)
Branch: 17.10_STABLE

commit 263eb365f89ade5b073a12c9a009a8b0553506c9
Author: Ghada El-Zoghbi <email address hidden>
Date: Tue May 29 13:50:13 2018 +1000

Bug 1773864: Throw MaharaException with valid error number

Pass error number and message correctly to the
MaharaException call when coming back from the
externalfeed curl call.

Sponsored by Central Queensland University

behatnotneeded

Change-Id: I03a2b666bde3905d2466ffbe35f1b35ca8a088bf
(cherry picked from commit 23287554e3c3d5398c118583e60de1cab8fabc36)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/8936
Committed: https://git.mahara.org/mahara/mahara/commit/09feb8b859532eafcd52595128b0a9041866d86e
Submitter: Robert Lyon (<email address hidden>)
Branch: 17.04_STABLE

commit 09feb8b859532eafcd52595128b0a9041866d86e
Author: Ghada El-Zoghbi <email address hidden>
Date: Tue May 29 13:50:13 2018 +1000

Bug 1773864: Throw MaharaException with valid error number

Pass error number and message correctly to the
MaharaException call when coming back from the
externalfeed curl call.

Sponsored by Central Queensland University

behatnotneeded

Change-Id: I03a2b666bde3905d2466ffbe35f1b35ca8a088bf
(cherry picked from commit 23287554e3c3d5398c118583e60de1cab8fabc36)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers