diff --git a/cli/Valet/Site.php b/cli/Valet/Site.php index 6240836..75d526b 100644 --- a/cli/Valet/Site.php +++ b/cli/Valet/Site.php @@ -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. * diff --git a/cli/app.php b/cli/app.php index 25078d2..4010044 100644 --- a/cli/app.php +++ b/cli/app.php @@ -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...');