From f50b7dbe11c82e2af19d84227d4a964d239f25c3 Mon Sep 17 00:00:00 2001 From: Tim Cieplowski Date: Wed, 20 Mar 2019 11:35:31 -0400 Subject: [PATCH] handle SSL .crt creation "Permission denied" failure --- cli/Valet/Site.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cli/Valet/Site.php b/cli/Valet/Site.php index aae9611..026a884 100644 --- a/cli/Valet/Site.php +++ b/cli/Valet/Site.php @@ -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); }