salesagility / SuiteCRM-Portal-Joomla

Joomla Plugin for the SuiteCRM Portal
GNU General Public License v2.0
22 stars 21 forks source link

Support Sugarcrm https sites properly #3

Closed adriangibanelbtactic closed 7 years ago

adriangibanelbtactic commented 8 years ago

This happened to us when using plugin from Joomla: Joomla Portal 1.1.1 for Joomla 3.x.zip . We suspect this is based on Joomla3 branch.

This issue only affects the ability to upload files to the Sugarcrm when the Sugarcrm url is setup as:

https://crm.domain.com

that it's with: https .

Either the problem is in:

A)

https://github.com/salesagility/SuiteCRM-Portal-Joomla/blob/eaf8aecf5641c4ce3effba420152f9f0adca0fb6/site/sugarRestClient.php#L68

$this->base_url = 'http://' . preg_replace( '~^http://~', '', $settings->sugar_url);

which I workaround with:

$this->base_url = 'https://' . preg_replace( '~^https://~', '', $settings->sugar_url);

but that should be updated with a proper sentence that handles both http or https.

B) Or in that $this->base_url is not used at all in many of the requests while the "Upload files" functions uses it.

Take a look at:

https://github.com/salesagility/SuiteCRM-Portal-Joomla/blob/eaf8aecf5641c4ce3effba420152f9f0adca0fb6/site/sugarRestClient.php#L351

$server =  $this->base_url."/soap.php?wsdl";

which uses $this->base_url .

Every other function on that file seems to use: rest_request function which seems not to use: $this->base_url but $this->rest_url instead.

So I guess that if you ever setup a Sugarcrm URL without http or https the normal functions won't work even if you initially planned to workaround it with $this->base_url .

Unless curl functions can use url without http:// at its beginning.

C) So the summary is:

C)1) I am able to workaround my problem by doing this change and I should not be able to do so.

https://github.com/salesagility/SuiteCRM-Portal-Joomla/blob/eaf8aecf5641c4ce3effba420152f9f0adca0fb6/site/sugarRestClient.php#L68

$this->base_url = 'http://' . preg_replace( '~^http://~', '', $settings->sugar_url);

which I workaround with:

$this->base_url = 'https://' . preg_replace( '~^https://~', '', $settings->sugar_url);

C)2) I suspect that autocomplete of url by prepending http (or https) does not work correctly in practice but I might be wrong.

boombata commented 7 years ago

Hi,

Thanks for the tip, it helped, adding the complete procedure with self signed certificate support.

  1. alter portal file /components/com_advancedopenportal/SugarRestClient.php (line 63) $this->base_url = 'http://' . preg_replace( '~^http://~', '', $settings->sugar_url); to: $this->base_url = 'https://' . preg_replace( '~^https://~', '', $settings->sugar_url);

2.if you are using self signed certificates, you should add the following at (line 93 ) curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

      curl_setopt($ch, CURLOPT_URL, $this->rest_url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch ,CURLOPT_ENCODING,'gzip');
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
         //to allow self signed certificates.
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1. same change to be applied on suitecrm side /modules/Administration/AOPAdmin.php (line 90) $cfg->config['aop']['joomla_url'] = 'http://' . preg_replace('~^http://~', '', $_REQUEST['joomla_url']); to $cfg->config['aop']['joomla_url'] = 'https://' . preg_replace('~^https://~', '', $_REQUEST['joomla_url']);

BM

chris001 commented 7 years ago

@boombata Could you fork this repo, make all these changes, and do a pull request against the "hotfix" branch.

boombata commented 7 years ago

@chris001 PR#8 submitted. I just removed the preg_replace as i'm not sure about its utility feel free to correct my lack of knowledge :)