explicitly set cert directory

pull/11626/head
Sharif Elgamal 2021-06-23 16:02:57 -07:00
parent 0932900abb
commit a602fc21d6
1 changed files with 3 additions and 10 deletions

View File

@ -1842,26 +1842,19 @@ func validateStartWithCorpProxy(ctx context.Context, t *testing.T, profile strin
_, err = Run(t, exec.CommandContext(ctx, "tar", "xzf", "mitmproxy-6.0.2-linux.tar.gz", "-C", mitmDir)) _, err = Run(t, exec.CommandContext(ctx, "tar", "xzf", "mitmproxy-6.0.2-linux.tar.gz", "-C", mitmDir))
if err != nil { if err != nil {
t.Fatalf("failed untar mitmproxy tar: %v", err) t.Fatalf("failed to untar mitmproxy tar: %v", err)
} }
// Start mitmdump in the background, this will create the needed certs // Start mitmdump in the background, this will create the needed certs
// and provide the necessary proxy at 127.0.0.1:8080 // and provide the necessary proxy at 127.0.0.1:8080
mitmRR, err := Start(t, exec.CommandContext(ctx, path.Join(mitmDir, "mitmdump"))) mitmRR, err := Start(t, exec.CommandContext(ctx, path.Join(mitmDir, "mitmdump", "--set", "confdir", mitmDir)))
if err != nil { if err != nil {
t.Fatalf("starting mitmproxy failed: %v", err) t.Fatalf("starting mitmproxy failed: %v", err)
} }
defer mitmRR.Stop(t) defer mitmRR.Stop(t)
// Find cert directory
homeDir, err := os.UserHomeDir()
if err != nil {
t.Fatalf("failed to find user home dir: %v", err)
}
certDir := path.Join(homeDir, ".mitmproxy")
// Add a symlink from the cert to the correct directory // Add a symlink from the cert to the correct directory
certFile := path.Join(certDir, "mitmproxy-ca-cert.pem") certFile := path.Join(mitmDir, "mitmproxy-ca-cert.pem")
destCertPath := path.Join("/etc/ssl/certs", "mitmproxy-ca-cert.pem") destCertPath := path.Join("/etc/ssl/certs", "mitmproxy-ca-cert.pem")
symLinkCmd := fmt.Sprintf("test -s %s && ln -fs %s %s", certFile, certFile, destCertPath) symLinkCmd := fmt.Sprintf("test -s %s && ln -fs %s %s", certFile, certFile, destCertPath)
if _, err := Run(t, exec.CommandContext(ctx, "sudo", "/bin/bash", "-c", symLinkCmd)); err != nil { if _, err := Run(t, exec.CommandContext(ctx, "sudo", "/bin/bash", "-c", symLinkCmd)); err != nil {