1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-04 16:10:08 +01:00

Remove Valet Certificate Authority on uninstall

This commit is contained in:
Matt Stauffer
2023-02-06 22:23:36 -05:00
parent 70b368126b
commit d5e6d6aab5
2 changed files with 31 additions and 0 deletions

View File

@@ -588,6 +588,35 @@ public function createCa($caExpireInDays)
$this->trustCa($caPemPath);
}
/**
* If CA and root certificates exist, remove them.
*
* @return void
*/
public function removeCa()
{
$caPemPath = $this->caPath('LaravelValetCASelfSigned.pem');
$caKeyPath = $this->caPath('LaravelValetCASelfSigned.key');
$caSrlPath = $this->caPath('LaravelValetCASelfSigned.srl');
$cName = 'Laravel Valet CA Self Signed CN';
if ($this->files->exists($caKeyPath)) {
$this->files->unlink($caKeyPath);
}
if ($this->files->exists($caPemPath)) {
$this->files->unlink($caPemPath);
}
if ($this->files->exists($caSrlPath)) {
$this->files->unlink($caSrlPath);
}
$this->cli->run(sprintf(
'sudo security delete-certificate -c "%s" /Library/Keychains/System.keychain',
$cName
));
}
/**
* Create and trust a certificate for the given URL.
*

View File

@@ -420,6 +420,8 @@ function (ConsoleCommandEvent $event) {
}
info('Removing certificates for all Secured sites...');
Site::unsecureAll();
info('Removing certificate authority...');
Site::removeCa();
info('Removing Nginx and configs...');
Nginx::uninstall();
info('Removing Dnsmasq and configs...');