diff --git a/clients/gplan.inc b/clients/gplan.inc index 9c87238..a5dc1de 100644 --- a/clients/gplan.inc +++ b/clients/gplan.inc @@ -31,7 +31,7 @@ class AppointmentsGPlanClient extends AppointmentsClientApi { // This triggers Exceptions by soap client. $options['exceptions'] = TRUE; - drupal_alter('dvg_appointment_soap_options', $options); + drupal_alter('dvg_appointments_soap_options', $options); try { $this->soap_client = new SoapClient($this->url, $options); diff --git a/clients/gplan_multiple.inc b/clients/gplan_multiple.inc index 7c0bfca..d779473 100644 --- a/clients/gplan_multiple.inc +++ b/clients/gplan_multiple.inc @@ -31,7 +31,7 @@ class AppointmentsGPlanMultipleClient extends AppointmentsClientApi { // This triggers Exceptions by soap client. $options['exceptions'] = TRUE; - drupal_alter('dvg_appointment_soap_options', $options); + drupal_alter('dvg_appointments_soap_options', $options); try { $this->soap_client = new SoapClient($this->url, $options); diff --git a/dvg_appointments.api.php b/dvg_appointments.api.php index 521ee77..c06a326 100644 --- a/dvg_appointments.api.php +++ b/dvg_appointments.api.php @@ -113,6 +113,51 @@ function hook_dvg_appointments_available_products_alter(&$available_products, $e } } +/** + * Alter the options used for the SoapClient. + * E.g. add 2 way SSL. + * + * @param array $options + * Options that are passed to the SoapClient. + */ +function hook_dvg_appointments_soap_options_alter(&$options) { + $opts = array( + 'ssl' => array( + 'verify_peer' => FALSE, + 'verify_peer_name' => FALSE, + 'local_cert' => '/path/to/my/fancy/cert', + 'passphrase' => 'wow so_s3cRet!', + ), + ); + $options['local_cert'] = $opts['ssl']['local_cert']; + $options['passphrase'] = $opts['ssl']['passphrase']; + $options['stream_context'] = stream_context_create($opts); +} + +/** + * Alter the options used for the drupal_http_request. + * E.g. add 2 way SSL. + * + * @param array $options + * Options that are passed to the drupal_http_request function. + * @param string $function + * Function the REST API is calling. + * @param string $rest_url + * REST URL that will be called. + */ +function hook_dvg_appointments_rest_options_alter(&$options, $function, $rest_url) { + // See available options: https://secure.php.net/manual/en/context.ssl.php + $opts = array( + 'ssl' => array( + 'verify_peer' => FALSE, + 'verify_peer_name' => FALSE, + 'local_cert' => '/path/to/my/fancy/cert', + 'passphrase' => 'wow so_s3cRet!', + ), + ); + $options['context'] = stream_context_create($opts); +} + /** * @} End of "addtogroup hooks". */ diff --git a/dvg_appointments.client.inc b/dvg_appointments.client.inc index 7691f68..4a092b8 100644 --- a/dvg_appointments.client.inc +++ b/dvg_appointments.client.inc @@ -41,6 +41,7 @@ abstract class AppointmentsClientApi { ); $options = $this->get_options($args, $method); + drupal_alter('dvg_appointments_rest_options', $options, $function, $rest_url); $response = drupal_http_request(url($rest_url, array('query' => $rest_url_parameters)), $options); $return = json_decode($response->data); if (isset($response->code) && isset($response->error)) {