forked from madeny/lhttps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenssl.php
More file actions
48 lines (38 loc) · 951 Bytes
/
Copy pathOpenssl.php
File metadata and controls
48 lines (38 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Madeny\lhttps;
use Symfony\Component\Dotenv\Dotenv;
class Openssl
{
public function __construct($path, $domainOne, $domainTwo)
{
$v3 = [
'authorityKeyIdentifier=keyid,issuer',
'basicConstraints=CA:FALSE',
'keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment',
'subjectAltName = @alt_names',
"[alt_names]",
"DNS.1 = {$domainOne}",
"DNS.2 = {$domainTwo}"
];
$str = implode("\n", $v3);
file_put_contents($path.'/cnf/v3.ext', $str);
$dotenv = new Dotenv();
$dotenv->load(realpath(__DIR__.'/../.env'));
$arr = [
getenv('R'),
getenv('D'),
getenv('P'),
getenv('DM'),
getenv('DN'),
getenv('D2'),
getenv('COUNTRY'),
getenv('STATE'),
getenv('LOCALITY'),
getenv('ORGANIZATION'),
getenv('ORGANIZATION_UNIT'),
getenv('EMAILADDRESS'),
getenv('COMMONNAME')];
$str = implode("\n", $arr);
file_put_contents($path.'/cnf/openssl.cnf', $str);
}
}