You are here

function lockr_admin_migrate_form_submit in Lockr 7.3

File

./lockr.admin.inc, line 103
Form callbacks for Lockr register form.

Code

function lockr_admin_migrate_form_submit($form, &$form_state) {
  $client_token = $form_state['values']['client_token'];
  $lc = lockr_client();
  try {
    $dn = [
      'countryName' => 'US',
      'stateOrProvinceName' => 'Washington',
      'localityName' => 'Tacoma',
      'organizationName' => 'Lockr',
    ];
    $result = $lc
      ->createCertClient($client_token, $dn);
  } catch (\Exception $e) {
    form_set_error('', t('An unknown error has occurred, please try again later.'));
    return;
  }
  $dir = "private://lockr/prod";
  _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);
}