I'm using drupal_http_request to parse some user details between servers.

Is it possible to secure drupal_http_request using https or should I fall back to cURL?

If there's a better way, do tell.

  • 1
    If you want to be sure that the other side is a trusted provider check this issue
    – wojtha
    Oct 18, 2012 at 10:47

3 Answers 3


Yes, it can.

case 'https':
  // ***************
  // Note: Only works when PHP is compiled with OpenSSL support.
  // ***************
  $port = isset($uri['port']) ? $uri['port'] : 443;
  $socket = 'ssl://' . $uri['host'] . ':' . $port;
  $options['headers']['Host'] = $uri['host'] . ($port != 443 ? ':' . $port : '');

Not sure if I am understanding you properly, but drupal_http_request() does handle https:// URLs. If you want to send a request to https://example.com, you can do it.



drupal_http_request doesn't correctly verify certificates, which makes it impossible to tell if you connected to the right server.

See https://drupal.org/node/1081192 for details and a path forward. This also includes a workaround you can deploy with some work.

  • 1
    I think OP wanted to know if it can handle an HTTPS URL just like an HTTP one. Thank you very much for posting the issue. Didn't realize there is such issue in the queue. Not sure how this would proceed with Guzzle though.
    – AKS
    Jan 16, 2014 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.