Jump Links

7 steps to fix SSL when it fails on Opencart 2.2.0.0

Back Posted on 23 Mar 2017

Opencart 2.2.0.0 is widely reported to have a number of bugs relating to configuring it to run on a secure SSL connection.

Having experienced this recently I found plenty of others had issues running Opencart 2.2.0.0 in SSL mode including

Fixes suggested often involve editing core files. This is bad practice as changes to the core will be overwritten during future updates. Instead use VQmod or OCmod to extend or update the core witout editing the original files.

Solution

Opencart user andreiwd kindly pulled the fixes required to force Opencart 2.2.0.0 to run securely into VQmod.

Installation + configuration

The VQmod file takes care of the bugs in Opencart 2.2.0.0 so all you need to do is configure opencart

  1. backup
  2. install an ssl certificate on your server
  3. update the server urls in Opencart

    config.php
    1. HTTP_SERVER
    2. HTTPS_SERVER

    /admin/config.php
    1. HTTP_SERVER
    2. HTTPS_SERVER
    3. HTTP_CATALOG
    4. HTTPS_CATALOG
  4. enable SSL System > Settings, Edit your store, on the Server tab under Security select Yes for Use SSL
  5. apply force https for opencart 2.2.0.0 with VQmod
  6. clear the cache at /system/storage/cache (a necessary step in my case as the navigation menu is written to file and wouldn't pick up url changes automatically)
  7. add redirect rules to force SSL in your web server config file (.htaccess for Apache, web.config for IIS)
  8. update any hard coded URLs using http in the database (example sql below)

Updating hard coded URLs

If your Opencart database includes URLs hard coded to http:// you should update them to https://.

Doing this manually by editing pages and products through the admin panel would be painfully slow and error prone. Thankfully there are better options

Updating the database directly

You can update your database directly through phpMyAdmin, Heidi or any similar tool. The examples below include some default Opencart tables and a few others relating to specific extensions.

Depending on your setup and extensions you will need to adjust the table names and search/replace strings appropriately.

UPDATE oc_menu SET link = replace(link,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_redirects SET to_url = replace(to_url,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_information_description SET description = replace(description,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_blog_article_description SET description = replace(description,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_product_description SET description = replace(description,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_product_tab_content SET content = replace(content,'http://www.domain.co.uk','https://www.domain.co.uk');

Resources