@@ -608,11 +608,33 @@ public function trustCertificate($crtPath, $url)
608
608
$ crtPath
609
609
));
610
610
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 ;
616
638
}
617
639
618
640
/**
@@ -670,7 +692,12 @@ public function unsecure($url)
670
692
$ this ->files ->unlink ($ this ->certificatesPath () . '/ ' . $ url . '.crt ' );
671
693
672
694
$ 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
+ }
674
701
}
675
702
}
676
703
0 commit comments