1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 08:30:07 +01:00

handle SSL .crt creation "Permission denied" failure

This commit is contained in:
Tim Cieplowski
2019-03-20 11:35:31 -04:00
parent 62edb056b4
commit f50b7dbe11

View File

@@ -304,11 +304,19 @@ function createCertificate($url)
$caSrlParam = ' -CAserial ' . $caSrlPath;
}
$this->cli->run(sprintf(
$result = $this->cli->runAsUser(sprintf(
'openssl x509 -req -sha256 -days 730 -CA "%s" -CAkey "%s"%s -in "%s" -out "%s" -extensions v3_req -extfile "%s"',
$caPemPath, $caKeyPath, $caSrlParam, $csrPath, $crtPath, $confPath
));
// If cert could not be created using runAsUser(), use run().
if (strpos($result, 'Permission denied')) {
$this->cli->run(sprintf(
'openssl x509 -req -sha256 -days 730 -CA "%s" -CAkey "%s"%s -in "%s" -out "%s" -extensions v3_req -extfile "%s"',
$caPemPath, $caKeyPath, $caSrlParam, $csrPath, $crtPath, $confPath
));
}
$this->trustCertificate($crtPath);
}