Issue Details (XML | Word | Printable)

Key: MDL-5374
Type: Bug Bug
Status: Open Open
Priority: Trivial Trivial
Assignee: Petr Skoda
Reporter: Imported
Votes: 0
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

poor https check

Created: 30/Apr/06 09:12 AM   Updated: 31/Dec/08 09:48 PM
Return to search
Component/s: Other
Affects Version/s: 1.6
Fix Version/s: 2.0

Environment: All
Issue Links:
Relates
 

Participants: C. Lopez, Imported, Martin Dougiamas and Petr Skoda
Security Level: None
Affected Branches: MOODLE_16_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
In all versions of Moodle, lib/weblib.php includes a snippet like this:



    if (isset($_SERVER['HTTPS'])) {

        $protocol = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';

    } else if (isset($_SERVER['SERVER_PORT'])) { # Apache2 does not export $_SERVER['HTTPS']

        $protocol = ($_SERVER['SERVER_PORT'] == '443') ? 'https://' : 'http://';

    } else {

        $protocol = 'http://';

    }



This doesn't work behind an SSL accelerator (an appliance that converts https: to http:). A better approach:



    if (isset($_SERVER['HTTPS'])) {

        $protocol = 'https://';

    } else if (strncmp($CFG->wwwroot, 'https', 5) == 0) {

        $protocol = 'https://';

    } else {

        $protocol = 'http://';

    }



Also, there are lots of snippets like str_replace('http','https', ...) that break if the host name accidentally includes 'http'. They must be str_replace('http:', 'https:', ...) at the least.



A still better approach would be to use relative URL! And the default protocol must always be derived from the $CFG->wwwroot, not from $_SERVER['HTTPS'] or the port number.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Michael Blake made changes - 21/Aug/06 05:01 PM
Field Original Value New Value
Assignee Petr Skoda [ petrskoda ] Petr ?koda [ skodak ]
Petr Skoda made changes - 16/Nov/06 02:08 AM
Fix Version/s 2.0 [ 10122 ]
Petr Skoda made changes - 17/Apr/08 05:52 AM
Status In Progress [ 3 ] Open [ 1 ]
Petr Skoda made changes - 31/Dec/08 09:48 PM
Link This issue has been marked as being related by MDL-17754 [ MDL-17754 ]