You are here

function lockr_admin_csr_submit in Lockr 7.2

1 string reference to 'lockr_admin_csr_submit'
lockr_admin_csr_form in include/csr_form.inc
Returns form array for CSR settings.

File

include/csr_form.inc, line 91
Form handlers for CSR admin settings.

Code

function lockr_admin_csr_submit($form, &$form_state) {
  $values = $form_state['values'];
  $dn = array(
    'countryName' => $values['country'],
    'stateOrProvinceName' => $values['state'],
    'localityName' => $values['city'],
    'organizationName' => $values['organization'],
  );
  variable_set('lockr_cert_dn', $dn);
  $site_client = lockr_site_client();
  try {
    $result = $site_client
      ->createCert($dn);
  } catch (LockrClientException $e) {
    watchdog_exception('lockr', $e);
    drupal_set_message('Please check form inputs.', 'error');
    return;
  } catch (LockrServerException $e) {
    watchdog_exception('lockr', $e);
    drupal_set_message('Lockr encountered an unexpected server error, please try again.', 'error');
    return;
  }
  $dir = "private://lockr/dev";
  _lockr_write_key_files($dir, $result);
  $private_wrapper = new DrupalPrivateStreamWrapper();
  $private_wrapper
    ->setUri("{$dir}/pair.pem");
  variable_set('lockr_cert', $private_wrapper
    ->realpath());
  variable_set('lockr_custom', TRUE);
}