Skip to content

Commit

Permalink
added option to ignore ssl cert file (#131)
Browse files Browse the repository at this point in the history
* Allow user to set the path to the pem cert file.
  • Loading branch information
pookmish authored and sherakama committed May 3, 2017
1 parent 88e6213 commit a842581
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 16 additions & 1 deletion includes/CAPx/APILib/AbstractAPILib.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,22 @@ protected function makeRawRequest($endpoint, $params = array(), $extraOptions =
}

// Provide a default cert PEM.
$options['verify'] = drupal_get_path("module", "stanford_capx") . "/includes/CAPx/APILib/cacert.pem";
$relative_pem_file = drupal_get_path("module", "stanford_capx") . "/includes/CAPx/APILib/cacert.pem";
$absolute_pem_file = drupal_realpath($relative_pem_file);
$which_pem = variable_get('stanford_capx_verify_pem', FALSE);

// Allow the option of using the bundled pem file.
if ($which_pem !== FALSE) {

// If the user set the var to a string use that. Otherwise go with the
// default.
if (is_string($which_pem)) {
$options['verify'] = check_plain($which_pem);
}
else {
$options['verify'] = $absolute_pem_file;
}
}

// This is bad idea. You should rely on the cert pem above.
if (variable_get("stanford_capx_ignore_ssl", FALSE)) {
Expand Down
7 changes: 7 additions & 0 deletions stanford_capx.forms.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,12 @@ function stanford_capx_config_auth_settings_form($form, &$form_state) {
'#required' => TRUE,
);

$form['advanced']['stanford_capx_ignore_ssl'] = array(
'#type' => 'checkbox',
'#title' => t('Ignore included certification file'),
'#default_value' => variable_get("stanford_capx_ignore_ssl", FALSE),
);

$form['#validate'][] = "stanford_capx_forms_connect_form_validate";
$form['#submit'][] = "stanford_capx_forms_connect_form_submit";

Expand Down Expand Up @@ -2222,6 +2228,7 @@ function stanford_capx_config_settings_form($form, &$form_state) {
*/
function stanford_capx_config_settings_form_submit($form, &$form_state) {
$values = $form_state["values"];
variable_set("stanford_capx_ignore_ssl", $values['stanford_capx_ignore_ssl']);
variable_set("stanford_capx_batch_limit", check_plain($values['stanford_capx_batch_limit']));
variable_set("stanford_capx_default_field_format", check_plain($values['stanford_capx_default_field_format']));
}
Expand Down

0 comments on commit a842581

Please sign in to comment.