Skip to content

Instantly share code, notes, and snippets.

@pounard
Created July 19, 2016 13:12
Show Gist options
  • Save pounard/6a40174d93925687b00a30cf1ab253fd to your computer and use it in GitHub Desktop.
Save pounard/6a40174d93925687b00a30cf1ab253fd to your computer and use it in GitHub Desktop.
drupal_http_request() ignore invalid certificates
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 : '');
if (empty($options['context'])) {
$options['context'] = stream_context_create();
}
stream_context_set_option($options['context'], 'ssl', 'verify_host', false);
stream_context_set_option($options['context'], 'ssl', 'verify_peer', false);
stream_context_set_option($options['context'], 'ssl', 'verify_peer_name', false);
stream_context_set_option($options['context'], 'ssl', 'allow_self_signed', true);
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment