class CertWriter in Lockr 8.3
Same name and namespace in other branches
- 8.4 src/CertWriter.php \Drupal\lockr\CertWriter
- 4.x src/CertWriter.php \Drupal\lockr\CertWriter
Utility class for handling writing certificates to the file system.
Hierarchy
- class \Drupal\lockr\CertWriter
Expanded class hierarchy of CertWriter
2 files declare their use of CertWriter
- LockrMigrateForm.php in src/
Form/ LockrMigrateForm.php - LockrRegisterForm.php in src/
Form/ LockrRegisterForm.php
File
- src/
CertWriter.php, line 8
Namespace
Drupal\lockrView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CertWriter:: |
public static | function | Writes certs for the given environment. |