function lockr_admin_migrate_submit in Lockr 7.2
1 string reference to 'lockr_admin_migrate_submit'
- lockr_admin_migrate_form in include/
migrate_form.inc
File
- include/
migrate_form.inc, line 23 - Form handlers for migrate admin settings.
Code
function lockr_admin_migrate_submit($form, &$form_state) {
$cert_file = variable_get('lockr_cert');
$cert_info = openssl_x509_parse(file_get_contents($cert_file));
$subject = $cert_info['subject'];
$dn = array(
'countryName' => $subject['C'],
'stateOrProvinceName' => $subject['ST'],
'localityName' => $subject['L'],
'organizationName' => $subject['O'],
);
$client = lockr_site_client();
try {
$result = $client
->createCert($dn);
} catch (LockrClientException $e) {
watchdog_exception('lockr', $e);
drupal_set_message('Please make sure that the current Lockr certificate is valid.', '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/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);
_lockr_rmtree('private://lockr/dev');
}