23 $destPath = empty($destPath) ?
$bearsamppRoot->getSslPath() : $destPath;
25 $subject =
'"/C=US/O=Bearsampp/CN=' . $name .
'"';
26 $password =
'pass:bearsampp';
27 $ppkPath =
'"' . $destPath .
'/' . $name .
'.ppk"';
28 $pubPath =
'"' . $destPath .
'/' . $name .
'.pub"';
29 $crtPath =
'"' . $destPath .
'/' . $name .
'.crt"';
34 $extContent = PHP_EOL .
'[' . $extension .
']' . PHP_EOL;
35 $extContent .=
'subjectAltName=DNS:*.' . $name .
',DNS:' . $name . PHP_EOL;
39 file_put_contents($conf, file_get_contents(
$bearsamppCore->getOpenSslConf()) . $extContent);
42 $confPath =
'"' . $conf .
'"';
45 $batch = $exe .
' genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -aes256 -pass ' . $password .
' -out ' . $ppkPath .
' -config ' . $confPath . PHP_EOL;
46 $batch .=
'IF %ERRORLEVEL% GEQ 1 GOTO EOF' . PHP_EOL . PHP_EOL;
49 $batch .= $exe .
' rsa -in ' . $ppkPath .
' -passin ' . $password .
' -out ' . $pubPath . PHP_EOL . PHP_EOL;
50 $batch .=
'IF %ERRORLEVEL% GEQ 1 GOTO EOF' . PHP_EOL . PHP_EOL;
53 $batch .= $exe .
' req -x509 -nodes -sha256 -new -key ' . $pubPath .
' -out ' . $crtPath .
' -passin ' . $password;
54 $batch .=
' -subj ' . $subject .
' -reqexts ' . $extension .
' -extensions ' . $extension .
' -config ' . $confPath . PHP_EOL;
55 $batch .=
'IF %ERRORLEVEL% GEQ 1 GOTO EOF' . PHP_EOL . PHP_EOL;
57 $batch .=
':EOF' . PHP_EOL;
58 $batch .=
'SET RESULT=KO' . PHP_EOL;
59 $batch .=
'IF EXIST ' . $pubPath .
' IF EXIST ' . $crtPath .
' SET RESULT=OK' . PHP_EOL;
60 $batch .=
'ECHO %RESULT%';
66 Util::logTrace(
'SSL Certificate generation for "' . $name .
'": ' . ($success ?
'SUCCESS' :
'FAILURE'));
85 return is_file($ppkPath) && is_file($pubPath) && is_file($crtPath);
102 return @unlink($ppkPath) && @unlink($pubPath) && @unlink($crtPath);
static exec($basename, $content, $timeout=true, $catchOutput=true, $standalone=false, $silent=true, $rebuild=true)
createCrt($name, $destPath=null)
static logTrace($data, $file=null)
static random($length=32, $withNumeric=true)