You are here

class CertWriter in Lockr 4.x

Same name and namespace in other branches
  1. 8.4 src/CertWriter.php \Drupal\lockr\CertWriter
  2. 8.3 src/CertWriter.php \Drupal\lockr\CertWriter

Utility class for handling writing certificates to the file system.

Hierarchy

Expanded class hierarchy of CertWriter

3 files declare their use of CertWriter
LockrMigrateForm.php in src/Form/LockrMigrateForm.php
LockrRegisterForm.php in src/Form/LockrRegisterForm.php
LockrRenewForm.php in src/Form/LockrRenewForm.php

File

src/CertWriter.php, line 8

Namespace

Drupal\lockr
View source
class CertWriter {

  /**
   * Writes certs for the given environment.
   */
  public static function writeCerts($env, $texts) {
    $base = "private://lockr/{$env}";
    @mkdir($base, 0750, TRUE);
    $key_file = "{$base}/key.pem";
    $key_fp = fopen($key_file, 'w');
    fwrite($key_fp, $texts['key_text']);
    fclose($key_fp);
    chmod($key_file, 0640);
    $cert_file = "{$base}/crt.pem";
    $cert_fp = fopen($cert_file, 'w');
    fwrite($cert_fp, $texts['cert_text']);
    fclose($cert_fp);
    chmod($cert_file, 0640);
    $pair_file = "{$base}/pair.pem";
    $pair_fp = fopen($pair_file, 'w');
    fwrite($pair_fp, $texts['key_text']);
    fwrite($pair_fp, $texts['cert_text']);
    fclose($pair_fp);
    chmod($pair_file, 0640);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CertWriter::writeCerts public static function Writes certs for the given environment.