You are here

function acquia_agent_stream_context_create in Acquia Connector 7

Same name and namespace in other branches
  1. 6.2 acquia_agent/acquia_agent_streams.inc \acquia_agent_stream_context_create()
  2. 6 acquia_agent/acquia_agent_streams.inc \acquia_agent_stream_context_create()
  3. 7.3 acquia_agent/acquia_agent.module \acquia_agent_stream_context_create()
  4. 7.2 acquia_agent/acquia_agent.module \acquia_agent_stream_context_create()

Builds a stream context based on a url and local .pem file if available.

2 calls to acquia_agent_stream_context_create()
AcquiaSearchService::prepareRequest in acquia_search/Acquia_Search_Service.php
Modify the url and add headers appropriate to authenticate to Acquia Search.
_acquia_agent_request in acquia_agent/acquia_agent.module
Send a XML-RPC request.

File

acquia_agent/acquia_agent.module, line 511
Acquia Agent securely sends information to Acquia Network.

Code

function acquia_agent_stream_context_create($url, $module = 'acquia_agent') {
  $opts = array();
  $uri = parse_url($url);
  if (isset($uri['scheme']) && $uri['scheme'] == 'https' && variable_get('acquia_agent_verify_peer', 0)) {

    // Look for a local certificate to validate the server identity.
    $pem_file = drupal_get_path('module', $module) . '/' . $uri['host'] . '.pem';
    if (file_exists($pem_file)) {
      $opts['ssl'] = array(
        'verify_peer' => TRUE,
        'cafile' => $pem_file,
        'allow_self_signed' => FALSE,
        // doesn't mean anything in this case
        'CN_match' => $uri['host'],
      );
    }
  }
  return stream_context_create($opts);
}