Skip to content
Snippets Groups Projects
Commit ad5f4a56 authored by Mariano Cano's avatar Mariano Cano
Browse files

Add flags for java and firefox.

parent 527d1a35
No related branches found
No related tags found
No related merge requests found
......@@ -16,9 +16,15 @@ func usage() {
}
func main() {
var uninstall, help bool
var uninstall, help, verbose bool
var java, firefox, noSystem, all bool
flag.Usage = usage
flag.BoolVar(&uninstall, "uninstall", false, "uninstall the given certificate")
flag.BoolVar(&java, "java", false, "install or uninstall on the Java truststore")
flag.BoolVar(&firefox, "firefox", false, "install or uninstall on the Firefox truststore")
flag.BoolVar(&noSystem, "no-system", false, "disables the install or uninstall on the system truststore")
flag.BoolVar(&all, "all", false, "install or uninstall on the system, Firefox and Java truststores")
flag.BoolVar(&verbose, "v", false, "be verbose")
flag.BoolVar(&help, "help", false, "show help")
flag.Parse()
......@@ -32,13 +38,31 @@ func main() {
os.Exit(1)
}
var opts []truststore.Option
if all {
opts = append(opts, truststore.WithJava(), truststore.WithFirefox())
} else {
if java {
opts = append(opts, truststore.WithJava())
}
if firefox {
opts = append(opts, truststore.WithFirefox())
}
}
if noSystem {
opts = append(opts, truststore.WithNoSystem())
}
if verbose {
opts = append(opts, truststore.WithDebug())
}
if uninstall {
if err := truststore.UninstallCertificate(flag.Arg(0)); err != nil {
if err := truststore.UninstallFile(flag.Arg(0), opts...); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
} else {
if err := truststore.InstallCertificate(flag.Arg(0)); err != nil {
if err := truststore.InstallFile(flag.Arg(0), opts...); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment