Skip to content

Commit

Permalink
Merge pull request #760 from ikari7789/refactor-create-certificate
Browse files Browse the repository at this point in the history
Fix issue with CA serial params
  • Loading branch information
mattstauffer authored Apr 8, 2019
2 parents 98b61f5 + e336ebc commit 001bb1f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cli/Valet/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,20 @@ function createCertificate($url)
$this->createPrivateKey($keyPath);
$this->createSigningRequest($url, $keyPath, $csrPath, $confPath);

$caSrlParam = ' -CAcreateserial';
if ($this->files->exists($caSrlPath)) {
$caSrlParam = ' -CAserial ' . $caSrlPath;
$caSrlParam = '-CAserial ' . $caSrlPath;
if (! $this->files->exists($caSrlPath)) {
$caSrlParam .= ' -CAcreateserial';
}

$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"',
'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"',
'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
));
}
Expand Down

0 comments on commit 001bb1f

Please sign in to comment.