You are here

function _lockr_write_key_files in Lockr 7.2

Same name and namespace in other branches
  1. 7.3 lockr.module \_lockr_write_key_files()

Writes key files.

Parameters

string $dir:

array $texts:

2 calls to _lockr_write_key_files()
lockr_admin_csr_submit in include/csr_form.inc
lockr_admin_migrate_submit in include/migrate_form.inc

File

./lockr.module, line 289
Hook implementations and callbacks for lockr.

Code

function _lockr_write_key_files($dir, array $texts) {
  mkdir($dir, 0700, TRUE);
  $key_file = "{$dir}/key.pem";
  $key_fd = fopen($key_file, 'w');
  fwrite($key_fd, $texts['key_text']);
  fclose($key_fd);
  chmod($key_file, 0600);
  $cert_file = "{$dir}/crt.pem";
  $cert_fd = fopen($cert_file, 'w');
  fwrite($cert_fd, $texts['cert_text']);
  fclose($cert_fd);
  chmod($cert_file, 0600);
  $pair_file = "{$dir}/pair.pem";
  $pair_fd = fopen($pair_file, 'w');
  fwrite($pair_fd, $texts['key_text']);
  fwrite($pair_fd, $texts['cert_text']);
  fclose($pair_fd);
  chmod($pair_file, 0600);
}