Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set HTTP proxy through CURLOPT_PROXY and CURLOPT_PROXYPORT #12

Open
grischard opened this issue Sep 30, 2020 · 6 comments
Open

Comments

@grischard
Copy link

grischard commented Sep 30, 2020

Curl options are hard-coded in CMRF/Connection/Curl.php, making it impossible to use an http proxy, which are required in some environments.

$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_URL, $profile['url']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSLVERSION, 1);

Ideally, it should be possible to set or override all of these curl options in a config file - I can for example imagine wanting to override CURLOPT_SSL_VERIFYPEER, CURLOPT_SSL_VERIFYHOST or CURLOPT_SSLVERSION in this context.

As a workaround, it is possible to edit CMRF/Connection/Curl.php locally, but that's obviously a hack.

@kwisatz
Copy link

kwisatz commented Sep 30, 2020

Well, ideally, the module wouldn't be using curl here at all, but use the HTTP API made available by drupal, which takes care of setting proxy settings globally if required.

@jensschuppe
Copy link
Contributor

The CMRF_Abstract_Core framework is supposed to be used without Drupal as well. If at all, this would be an option for the cmrf_core Drupal module.

@kwisatz
Copy link

kwisatz commented Sep 30, 2020

The CMRF_Abstract_Core framework is supposed to be used without Drupal as well. If at all, this would be an option for the cmrf_core Drupal module.

OK, I see. Yeah, maybe it can swap out the HTTP Api/Implementation based on where it's being used.
In any case, to add to @grischard 's example above, we found that proxies also don't like requests that don't present a user agent, so CURLOPT_USERAGENT should also be set to some string identified the CMRF Core.

@jaapjansma
Copy link
Contributor

It uses curl and it make sense to add configuration for proxy settings and other parameters (in the case reproted by @grischard we also had to set the User Agent header)

@jensschuppe
Copy link
Contributor

I'd vote for passing configuration through code instead of using a config file, since the latter wouldn't allow for an easy configuration UI e.g. in Drupal. An implementation of hook_cmrf_core_connectors_alter() could then be used to add the config params to override defaults.

@jaapjansma
Copy link
Contributor

Agree and we can easily add our own connection classes in custom modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants