diff --git a/background_process.admin.inc b/background_process.admin.inc index 40a3248..0bdf9ec 100755 --- a/background_process.admin.inc +++ b/background_process.admin.inc @@ -68,6 +68,13 @@ function background_process_settings_form() { '#default_value' => variable_get('background_process_default_service_host', 'default'), ); + $form['background_process_ssl_verification'] = array( + '#type' => 'checkbox', + '#title' => t('SSL verification'), + '#description' => t("Don't turn this off on production environments, as it will raise security issues"), + '#default_value' => variable_get('background_process_ssl_verification', TRUE), + ); + $methods = module_invoke_all('service_group'); $options = background_process_get_service_groups(); foreach ($options as $key => &$value) { diff --git a/background_process.module b/background_process.module index b717202..49c30a8 100755 --- a/background_process.module +++ b/background_process.module @@ -1070,6 +1070,14 @@ function background_process_http_request($url, array $options = array()) { return _background_process_http_request_result($result); } + // Set default context to enable/disable SSL verification. + $default_context = stream_context_create(array( + 'ssl' => array( + 'verify_peer' => variable_get('background_process_ssl_verification', TRUE), + 'verify_peer_name' => variable_get('background_process_ssl_verification', TRUE), + ), + )); + // Merge the default options. $options += array( 'headers' => array(), @@ -1077,7 +1085,7 @@ function background_process_http_request($url, array $options = array()) { 'data' => NULL, 'max_redirects' => 3, 'timeout' => variable_get('background_process_connection_timeout', BACKGROUND_PROCESS_CONNECTION_TIMEOUT), - 'context' => NULL, + 'context' => $default_context, 'blocking' => FALSE, 'postpone' => FALSE, );