srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mitmuxd/main.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/cmd/mitmuxd/main.go b/cmd/mitmuxd/main.go
index 9db31e5..9c77516 100644
--- a/cmd/mitmuxd/main.go
+++ b/cmd/mitmuxd/main.go
@@ -7,11 +7,13 @@ package main
import (
"context"
"flag"
+ "fmt"
"log"
"net"
"os"
"os/signal"
"path/filepath"
+ "runtime"
"syscall"
"time"
@@ -26,6 +28,7 @@ func main() {
caDir := flag.String("ca-dir", "", "directory for CA cert/key and history db (default: XDG config dir)")
dbPath := flag.String("db", "", "path to history database (default: <ca-dir>/history.db)")
socketPath := flag.String("socket", "", "control socket path (default: $XDG_RUNTIME_DIR/mitmux.sock, else <ca-dir>/mitmux.sock)")
+ installCA := flag.Bool("install-ca", false, "generate the CA if needed, print OS-specific trust-store install steps, and exit (doesn't start the proxy)")
flag.Parse()
dir := *caDir
@@ -41,7 +44,14 @@ func main() {
if err != nil {
log.Fatalf("load CA: %v", err)
}
- log.Printf("CA ready: %s (install %s/ca.pem in your client's trust store to avoid TLS warnings)", root.Cert.Subject.CommonName, dir)
+
+ if *installCA {
+ fmt.Printf("CA certificate: %s\n\n", ca.CertPath(dir))
+ fmt.Print(ca.InstallInstructions(runtime.GOOS, ca.CertPath(dir)))
+ return
+ }
+
+ log.Printf("CA ready: %s (install %s/ca.pem in your client's trust store to avoid TLS warnings, or run 'mitmuxd -install-ca' for OS-specific steps)", root.Cert.Subject.CommonName, dir)
dbFile := *dbPath
if dbFile == "" {