Skip to content

Commit c4f655d

Browse files
committed
fix install certificates on firefox
1 parent a8d22a4 commit c4f655d

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

cli/Valet/Site.php

+33-6
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,33 @@ public function trustCertificate($crtPath, $url)
608608
$crtPath
609609
));
610610

611-
$this->cli->run(sprintf(
612-
'certutil -d $HOME/.mozilla/firefox/*.default -A -t TC -n "%s" -i "%s"',
613-
$url,
614-
$crtPath
615-
));
611+
foreach ($this->getFirefoxProfilePath() as $path) {
612+
$this->cli->run(sprintf(
613+
'certutil -d ' . $path . ' -A -t TC -n "%s" -i "%s"',
614+
$url,
615+
$crtPath
616+
));
617+
}
618+
}
619+
620+
/**
621+
* get profiles paths of firefox
622+
*
623+
* @return array
624+
*/
625+
private function getFirefoxProfilePath() {
626+
$firefoxPath = getenv('HOME').'/.mozilla/firefox/';
627+
$profiles = 'profiles.ini';
628+
$path = [];
629+
if(file_exists($firefoxPath . $profiles)){
630+
$ini = parse_ini_file($firefoxPath . $profiles, true);
631+
foreach($ini as $key => $value){
632+
if(str_starts_with($key, 'Profile')){
633+
$path[] = ((bool)$value['IsRelative']) ? $firefoxPath . $value['Path'] : $value['Path'];
634+
}
635+
}
636+
}
637+
return $path;
616638
}
617639

618640
/**
@@ -670,7 +692,12 @@ public function unsecure($url)
670692
$this->files->unlink($this->certificatesPath() . '/' . $url . '.crt');
671693

672694
$this->cli->run(sprintf('certutil -d sql:$HOME/.pki/nssdb -D -n "%s"', $url));
673-
$this->cli->run(sprintf('certutil -d $HOME/.mozilla/firefox/*.default -D -n "%s"', $url));
695+
foreach ($this->getFirefoxProfilePath() as $path) {
696+
$this->cli->run(sprintf(
697+
'certutil -d ' . $path . ' -D -n "%s"',
698+
$url
699+
));
700+
}
674701
}
675702
}
676703

0 commit comments

Comments
 (0)